0
I can't understand this while loop please someone explain me how it'll work?
words = ["hello", "world", "spam", "eggs"] counter = 0 max_index = len(words) - 1 while counter <= max_index: word = words[counter] print(word + "!") counter = counter + 1
1 Answer
+ 1
max_index = 3
as long as counter is smaller than 3 it stays true then an element with the index of the value of counter will be assigned to word the current word will be printed with an exlamation mark and the counter will be increased by one
this continues for all elements in words understandable?