Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to find the shortest word in a list python

def findShortest(lst):
    length = len(lst)
    short = len(lst[0])
    ret = 0
    for x in range(1, length):
        if len(lst[x]) < short:
            short = lst[x]
            ret = x

    return x # return the index of the shortest sentence in the list
Source by www.daniweb.com #
 
PREVIOUS NEXT
Tagged: #find #shortest #word #list #python
ADD COMMENT
Topic
Name
1+6 =