print the length of the longest string in the list
问题 I am having difficulties print the length of the longest string in the list which is kevin07 which should equal to 7. My current solution prints all 3 item lengths. names = ['ron', 'james', 'kevin07'] best = 0 for index in range(len(names)): if len(names[index]) > best: best = len(names[index]) print(best) 回答1: names = ['ron', 'james', 'kevin07'] best = 0 for index in range(len(names)): if len(names[index]) > best: best = len(names[index]) print(best) Output: 7 Explanation: You need to move