0

words = ["hello", "world", "spam", "eggs"] for word in words: print(word + "!")

What does this "word in words" means

18th Jul 2018, 4:00 AM
ADITYA SINHA
ADITYA SINHA - avatar
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 + "!")
18th Jul 2018, 4:09 AM
Satyam
+ 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.....
18th Jul 2018, 11:36 AM
Maninder $ingh
Maninder $ingh - avatar