0
Can we iterate lists?
4 ответов
+ 4
lst = [1,2,3,4,5]
for x in lst:
print(x)
+ 1
adarsh pandey
you can iterate over list by using generator like below,
def iter(n):
for i in n:
yield i
mygenerator = iter([1,1,2,4,5])
for i in mygenerator:
print(i)
0
adarsh pandey
very well
0
thanks
but then what is the difference between generators and lists