0
words = ["hello", "world", "spam", "eggs"] for word in words: print(word + "!")
What does this "word in words" means
2 Answers
+ 4
it means 'for every element in list words'. but instead of every element it is using the name 'word'.
This has the same result.
words = ["hello", "world", "spam", "eggs"]
for i in words:
print(i + "!")
+ 1
it means that.
word is using words list.
for loop is iterate 5 times because words list has 5 values in it.
when word iterate first time it's value is hello because for loop starts from the first element of the list but it can be changed.next time it's value is world and then.....