Question: The Python code segment below prints the length of the longest string contained in a non-empty list of strings called words: YOUR TASK is to
The Python code segment below prints the length of the longest string contained in a non-empty list of strings called words:
YOUR TASK is to complete the code below so that it also prints the length of the longest string contained in the list words. Note that the code below is virtually the same as the code above, except for the first two lines and the gaps.
best = words[0]
for word in words: if len(word) > Term 1 bestwords[best]wordwords[0]len(words[best])len(best)len(words[index])words[index]words[word]: best = Term 2 bestwords[best]wordwords[0]len(words[best])len(best)len(words[index])words[index]words[word] print("longest word length is:", Term 3 bestwords[best]wordwords[0]len(words[best])len(best)len(words[index])words[index]words[word])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
