Why do we create two separate empty lists to generate a 2D array?

In the code below, what is the reason for looping through to generate one list and then append one list to another list? Why not just use the first list that was generated?

Screen Link:

converted_taxi_list = []
for row in taxi_list:
    converted_row = []
    for item in row:
1 Like

@Willyjgolden: If you use just the first list, this would mean that the final output will be a 1D array, not 2D. In this case, we have a nested for loop, the inner loop to create each row and the outer loop to “stack” the rows together. Hope this clarifies!

1 Like