0
Elements of a list
in this example: words = ["hello", "world", "spam", "eggs"] for word in words: print(word + "!") How it knows that "word" is an element of the list? It works the same with random text: list = ["hello", "world", "spam", "eggs"] for plane in list: print(plane + "!")
2 Réponses
+ 1
The word in the for statement, is called an "iteration variable". It's value will be different in each cycle, taking all the values one by one from the iterator (something after the "in" keyword). The iterator can be a list, a string, a range of numbers for example.