Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Get more than one longest word in a list python

words = ['hello','sample,'word','about','hey','longes','mikeys']
# the code:
longestWord = max(words,key=len)				# will get the longest word
length = len(longestWord)						# will get the length of the longest word
long_word = [i for i in words if len(i) == length]	# list comprehension thatt will get all the longest word in the list
Source by www.kite.com #
 
PREVIOUS NEXT
Tagged: #Get #longest #word #list #python
ADD COMMENT
Topic
Name
4+7 =