Dears,
I wrote the code to create a generator but no sucess, I tried to wrote
running another ways but no sucess, the code is simple:
def gen(lista):
for elemento in lista:
yield elemento
gerador = gen([1, 2, 3, 4, 5])
print(next(gerador))
x= geradores()
print(next(x))
I think the reason is, the output always is:
>>>1
>>>1
>>>1
>>>1
>>>1
instead:
>>>1
>>>2
>>>3
>>>4
>>>5
How can I solve this?
--
You received this message because you are subscribed to the Google Groups
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.