Python: Finding Longest/Shortest Words In a List and Calling Them in a Function
问题 I have a list of words: words=["alpha","omega","up","down","over","under","purple","red","blue","green"] I have two functions that are supposed to find the shortest and longest words in this list: def bigWords(list=[], *args): largestWord="" largestLen=0 for word in list: if largestWord<len(word): largestWord=len(word) largestWord=word print "The longest word(s) in the list is %s." % largestWord def smallWords(list=[], *args): smallestWord="" smallestLen=0 for word in list: if smallestLen>len