0

Why always for loops are used with Generators in python

https://code.sololearn.com/cMgYt4kw5sqm/?ref=app

10th Aug 2022, 1:50 PM
SAIF ALI
SAIF ALI - avatar
2 odpowiedzi
+ 1
You don't always have to use for loop with generators: def g(): yield 1 yield 2 yield 3 a = g() print(next(a)) print(next(a)) print(next(a))
11th Aug 2022, 6:55 PM
Seb TheS
Seb TheS - avatar
0
Seb TheS Well bruh can't we utilize the general within the print statement like this: print(g()) and also this give the name of the function/generator
12th Aug 2022, 5:07 AM
SAIF ALI
SAIF ALI - avatar