I am having trouble understanding how functions work with nested lists. For example:
def function(x):
return (i for i in x)
x = function([[99, 0], [0, 99]])
print(list(x))
Gives the result:
[[99, 0], [0, 99]]
However, this code:
def function(x):
for i in x:
return i
x = function([[99, 0], [0, 99]])
print(list(x))
Gives:
[99, 0]
Why doesn't the second code print the second component of the list?