I'm doing this exercise:
Write a Python program that gives two options to the user to either find the shortest string in a string list or the lowest element of an integer list. The program should read the two lists in both cases and handle any invalid inputs as well. Explain how can you use the top-down approach to analyze and design your model.
def findShortest(stringList):
indexofshortest = 0
shortest = stringList[0]
length = len(stringList)
for index in range(1,length):
current = stringList[index]
print("Current string is:",current)
if len(current)<len(shortest):
print("This is Shorter than:",shortest)
shortest = current
indexofshortest = index
return indexofshortest
print(findShortest(["abc","bc","c"]))
def longestLength(a):
max1 = len(a[0])
temp = a[0]
for i in a:
if(len(i) > max1):
max1 = len(i)
temp = i
print("The word with the longest length is:", temp,
" and length is ", max1)
a = ["one", "two", "third", "four"]
print(longestLength(a))
How can I connect the functions together?