Question: Consider a non-empty Python list variable called words which contains strings Below is incomplete code which is i tended to print the longest tring n


Consider a non-empty Python list variable called words which contains strings Below is incomplete code which is i tended to print the longest tring n the list words Two The code is supposed to work by scanning across he list usung he variable best to keep track of the longest word seen so far. ways to do this are: () remember the word using the variable best; or (2 reember the word's position in the list using the variable best. Each box contains a number of labelled lines of code which would be used for the implementations above. They are not in any particular order. YOUR TASK is to first make a choice about which implementation you will use (it does not matter which). Then determine which combination of lines of code will cause the code to print the longest string in the list words bestEither: or: (a) 0 (b) words [0] for index in range (len (words)) Either: (a) (b) len (words [best]) len (best) if len (words[index] ) > or: Either: (a) words [index] (b) index best or: print Either: (a words [best] (b) best or
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
