0

Can we iterate lists?

12th Jul 2018, 4:39 PM
adarsh pandey
adarsh pandey - avatar
4 ответов
+ 4
lst = [1,2,3,4,5] for x in lst: print(x)
12th Jul 2018, 4:40 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 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)
12th Jul 2018, 5:17 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
0
adarsh pandey very well
12th Jul 2018, 4:49 PM
Dlite
Dlite - avatar
0
thanks but then what is the difference between generators and lists
13th Jul 2018, 4:51 PM
adarsh pandey
adarsh pandey - avatar