+ 1
If Im using a loop "for in" didnt I have to declare variable? Like: words = ["hello", "world", "spam", "eggs"] for word in words: print(word + "!") variable word is not declared..
2 Réponses
+ 3
of course, you have to tell python, through what to make a for loop
in statement "for word in words":
"word" is a name of a dynamic variable, created only for this loop
"words" is a name of iterable object, like list, tuple, string, range etc. it must be declared before or right now (like range) to use it properly in loop
0
Great tnx!