Help to understand | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Help to understand

second cycle 'for' doesnt work. why? https://code.sololearn.com/cOvsKRGS3q77/?ref=app

23rd Apr 2018, 9:33 PM
andrey
andrey - avatar
8 Answers
+ 2
c is a generator. You can only traverse or iterate over it once.
23rd Apr 2018, 9:41 PM
cyk
cyk - avatar
+ 2
23rd Apr 2018, 9:42 PM
cyk
cyk - avatar
+ 2
Look. If you want you can convert generator to list. For loops will work all the time https://code.sololearn.com/cgIB2uO0ur1Y/?ref=app
23rd Apr 2018, 10:05 PM
cyk
cyk - avatar
+ 2
thanks again!!!!
23rd Apr 2018, 10:10 PM
andrey
andrey - avatar
+ 2
a'm learning python only month. by myself. its my first experience.
23rd Apr 2018, 10:12 PM
andrey
andrey - avatar
+ 2
You seem to be doing fine... And when you have questions we are here to help ☺☺
23rd Apr 2018, 10:16 PM
cyk
cyk - avatar
+ 1
Oh sorry! What is says is that yield creates a generator and generator can only be iterated over one time That is why your first for loop works but not the second ☺
23rd Apr 2018, 10:00 PM
cyk
cyk - avatar
0
good article. but english difficult for me to understand completly(((
23rd Apr 2018, 9:59 PM
andrey
andrey - avatar