l = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]
for i in l :
for j in i:
print(j, end = " ")
i m not able to understand dry run of this code ?
l = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]
for i in l :
for j in i:
print(j, end = " ")
i m not able to understand dry run of this code ?
Hey @coding123c
Hoping you are familiar with the concept of for loop before diving into the dry run of the above code:
for the 1st iteration:
i will take the value present at the 0th index of list l i.e. [1,2,3]
now the code will move to the 2nd for loop i.e. for j in i this statement will run till we reach end of the list i starting from 0th index of list i, hence it will be printing
1 2 3
as explained for 1st iteration rest of the iteration will also follow the similar pattern until loop 1 reaches the end of list l
Hope this might helps