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(word):
smallestLen>len(word)
smallestWord=word
print "The shortest word(s) in the list is: %s." % (smallestWord)
I have these functions nested so I can call them all at once:
def callFunctions():
###Words###
words=["alpha","omega","up","down","over","under","purple","red","blue","green"]
wordLength=lenList(words)
print "The amount of words[] is %d" % wordLength
func_list2 = [bigWords, smallWords]
for f in func_list2:
map(f, words)
callFunctions()
This is just returning this without inputing the words in the list:
The longest word(s) in the list is .
The longest word(s) in the list is .
The longest word(s) in the list is .
The longest word(s) in the list is .
The longest word(s) in the list is .
The longest word(s) in the list is .
The longest word(s) in the list is .
The longest word(s) in the list is .
The longest word(s) in the list is .
The longest word(s) in the list is .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
The shortest word(s) in the list is: .
Not sure why, any help is appreciated.