write a python program to find the longest words

Solutions on MaxInterview for write a python program to find the longest words by the best coders in the world

showing results for - "write a python program to find the longest words "
Debora
09 May 2016
1max(a_list, key=len)
Bronwen
22 Mar 2016
1def longestword(filename):
2	with open(filename,'r+') as f:
3		words = f.read().split()
4		max_len_word = max(words,key=len)
5		max_len = len(max(words,key=len))		
6		print('maximum lenth word in file :',max_len_word)
7		print('lenth is : ',max_len)
8
9longestword('file1.txt')
10
11or 
12
13def longest_word(filename):
14    with open(filename, 'r') as infile:
15              words = infile.read().split()
16    max_len = len(max(words, key=len))
17    return [word for word in words if len(word) == max_len]
18
19print(longest_word('file1.txt'))
20
queries leading to this page
largest string pythondetermine the longest word in a string pythonpython find max length in listfind longest word in string pythonfind longest word in pythonmax length string in list pythonwhat should be the longest python variable name 3fhow to get the longest string in a list pythonfind longest matching substring pythonprint longest common substring pythonwrite a python program to find the longest words how to find longets item in a python string listhow to find longest sequence in python stringfind the biggest stringwrite a python program to find the longest word in a given sentenceget the longest string in a list pythonlongest python codepython get string with max lengthlongest element in list pythonlongest word in a string pythonwrite a program to find the longest word in a file pythonhow to find the longest string pythonpython program to find the longest word in a stringlongest program code in pythonpython longest numberpython get the longest string in a listlongest word in string pythonfind the longest name in string pythonpython longest word in stringget longest len pythongiven a text as input 2c find and output the longest word pythonfind longest word in a string pythonlongest python scriptlongest python in the worldprint the longest variable value in pythonhow to find the longest word in a string pythonpython find the longest word in a stringlongest substringg pythonall longest string pythonreturn array of longest strings pythonlongest string pythonfind longest sentence in pythonlongest string in list pythonfind the longest palindrome in a stringfind longest string that appears at end of other string pythonhow to get the longest string in a set pythonfind min and max len words in list pythnpython method that findds the longest element stringlongest common substring pythonhow to get the longest match pytohnget max length of elements in list pythonlocate longest word in python stringget length of longest string in list pythonfind the longest 0s in a string pythonlength of longest substring solution pythonfind longest word python in stringprint longest common substring in pythoncheck the longest space in a string pythonpython get longest run of charactershow to finf the longest string in a for loop in pythonreturn longest string in list pythonmax length of string in list pythonhow can i find the longest string in pythonfind longest match pythonpython max character listlongest substring in pyhtonlongest substring find in pythonwrite a program to find the longest word in the list pythonlongest python code in the worldreturn string with longest length pythonlongest possible strings using pythonprogram to find longest word in a string in pythonpython longest wordsget longest word in string pythonfind the longest substring in a string pythonpython how to find the longest word in stringlength of the longest valid substring pythonlongest string match pythonhow to find longest possible substrings of a string in pythonselect string with longest length python19 write a python program to find the longest words longest word in a string in pythonreturn longest string pythonlongest substring using pythonhow to find string length from listpython find the longest string in a listpython program to find maximum length of stringlongest substring in pythonfind longest vovel in string pythonpython find longest word in stringfind longest str in listget max length of string in list pythonpython get longest string in listreturn longest word pythonpython program to find the longest words in different sentencepython longest sentencepython find longest substringhow to check whats the longest string from 3 in pythonpython longest stringfind longest words in a string pythonpython program to find maximum length of string from a input longest palindromic substring pythonpython longest wordpython largest string in listhow to find longest string in pythonprint longest string and length pythonpython longest substringthe longest string in pythonlongest words in a string pythonfind longest string that appears at end of another string pythonhow to get the the longest word in a string in pythonget longest word in string python3python take longest word in stringhow to find the longest string in a list pythonfind the longest word in a string pythonlongest common substring in pythonhow to find out who has the longest name in pythonwrite a python program to find the longest words from a file longest words in pythonget the longest match in a string pythonlongest word pythonhow to find out who has the longest name in python in a looppython program to find the longest wordsreturn the longest word in a string pythonmax string length in list pythonfind the longest substring in pythonget longest of two strings pythonwrite a program to find the longest word in a text file pythonfind longest string in list pythonget longest string in list pythonfind longest word pythonlongest word in pythonthe longest string pythonfind longest string in pythonlongest string in sentence using python python get longest word value in stringprint longest word in a string pythonlongest way to print a string in pythonmax in python lengthlongest pythonmax length in pythonlongest substring pythonhow to find longest substring in pythonpython program to find longest word from sentence in pythonpython longest string in listpython program to find the longest word in a given sentencereturn longest word in string pythonhow to find longest word in a list pythonhow to find longest word in a string pythonpython find shortest string in listfind the longest word in oythonfind longest word in sentence pythonpython find longest substring in stringhow to display the longest word in a string pythonwrite a python program to find the longest words