python Basic Level Generator und Liste Fragen [duplizieren]
Diese Frage hat hier bereits eine Antwort:
Python 2 seltsame Liste Verständnis Verhalten 2 Antwortenmy_nums =(i*i for i in [1,2,3,4,5])
for k in (my_nums):
print(k)
GG = list(my_nums)
print(GG)
Es wird gedruckt:
1
4
9
16
25
[]
Process finished with exit code 0
Ich kann nicht verstehen, warum ist[]
Wert leer (es sollte @ se[1,4,9,16,25]
)? Tut auchfor-loop
Generatorwerte in Liste konvertieren?