how to find the shortest word in a list python

Solutions on MaxInterview for how to find the shortest word in a list python by the best coders in the world

showing results for - "how to find the shortest word in a list python"
Melina
20 Jan 2020
1def findShortest(lst):
2    length = len(lst)
3    short = len(lst[0])
4    ret = 0
5    for x in range(1, length):
6        if len(lst[x]) < short:
7            short = lst[x]
8            ret = x
9
10    return x # return the index of the shortest sentence in the list