+ 2
I don't understand 'word' in this program.
words = ["hello", "world", "spam", "eggs"] for word in words: print(word + "!") for 'word', what is this??
6 Answers
+ 2
This one really helped, because I am learning java.
+ 1
thankyou
+ 1
So, the 'word' is like a variable, I suppose.
+ 1
its just like you saying for a number in (1/2/3/4)
+ 1
It means for every word inside the "words" array.
you can replace "word" with anything you want. like item
+ 1
Equivalent would be
string[] words = ["hello","world","spam","eggs"]
for (int i=0;i < words.length; i++){
string word = words[i]
print(word+"!")
}
foreach more or less does that for you.