0
for loops
words = ["hello", "world", "spam", "eggs"] counter = 0 max_index = len(words) - 1 while counter <= max_index: word = words[counter] print(word + "!") counter = counter + 1 what does the [counter] in the 6th line represent? or why do we have to put it there? .please explain.
1 Answer
+ 2
The Counter represents the Index of an Item in the List Words.
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2431/
But this is a realy complicated Solution. You can reach the same Output with:
words = ["hello", "world", "spam", "eggs"]
for word in words:
print(word + "!")