How to solve the longest word problem? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to solve the longest word problem?

How to find the longest word in this, "This is a test text" #python

3rd Oct 2021, 1:05 PM
Vaibhav Tiwari
4 Answers
+ 1
Your attempt?
3rd Oct 2021, 2:02 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 1
Thanks I did it
3rd Oct 2021, 2:07 PM
Vaibhav Tiwari
+ 1
Lol OK.
3rd Oct 2021, 2:11 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
0
txt = input() #your code goes here dic = {} words = txt.split(" ") for i in words: lenth = len(i) dic[i]=lenth maxi = max(dic, key = dic.get) print(maxi)
27th Mar 2022, 8:12 AM
_Avi_
_Avi_ - avatar