Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get longest shortest word in list python

words = ["alpha","omega","up","down","over","under","purple","red","blue","green"]

#GET LONGEST WORD
max(words, key=len)
>>> 'purple'

#GET SHORTEST WORD
min(words, key=len)
>>> 'up'
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #longest #shortest #word #list #python
ADD COMMENT
Topic
Name
4+8 =