0
words = ["hello", "world", "spam", "eggs"] counter = 0 max_index = len(words) - 1 while counter <= max_index: word = words
I can't understand about 'counter=0' and. "while counter <= max_index:ï»żword = words" and this please explain about this to me!!!!!!!
4 Answers
+ 1
What ist the purpose of your Code? What Output do you expect?
+ 2
What it does:
words = ["hello", "world", "spam", "eggs"]
# defines a List of 4 Words
counter = 0
# defines an integer that is Zero
max_index = len(words) - 1
# defines another integer that is 3
while counter <= max_index:
# Starts a Loop that will Stop when the condition is true
word = words
# creates a Copy of the List
The Loop will run Infinite. There will be no Output.
What can you do?
Print all Words in your List with the number of Characters:
words = ["hello", "world", "spam", "eggs"]
counter = 0
max_index = len(words) - 1
while counter <= max_index:
print (words[counter], len (words[counter]))
counter += 1
Or better:
words = ["hello", "world", "spam", "eggs"]
for i in words:
print (i, len (i))
0
actually what it can do
0
thanks