I'm working on an assignment where I have to have someone input a string of words and my program is supposed to then pick out the length of the shortest and longest word in that string. I've successfully had it pick out the length of the longest word:
def longWord(string):
alist = []
length = 0
for letter in string:
if letter != " ":
length +=1
else:
alist.append(length)
length = 0
return alist
So if the input is "happy day", my print function tells me that the longest word is 5 characters.
However, for the life of me I can't figure out how to write something that will pick out the length of the shortest word in the input string. How would I do this?