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.
2 Answers
0
Just to add to what ćļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć said:
'words' is a list. In lists you use:
list_name[index]
to access the values in the list.
In the code you mention, counter is used as the index for
accessing the elements of list 'words'.
When counter = 0 you get the first element, when it is 1, the second ...
0
thanks guys ... now i see it š