How can i solve longest word problem in python. When u need any input from user and then u have figure out longest word. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can i solve longest word problem in python. When u need any input from user and then u have figure out longest word.

This is the code txt = input() str_list = txt.split() # list_s = sorted(str_list, key=len) print(list_s[-1])

6th Dec 2020, 3:59 AM
Harjot Singh
5 Answers
+ 5
Harjot Singh I believe the code is working fine! So where you are having issue in understanding?
6th Dec 2020, 11:12 AM
Piyush
Piyush - avatar
+ 2
First show your attempt here
6th Dec 2020, 4:03 AM
Sâñtôsh
Sâñtôsh - avatar
+ 2
Harjot Singh please show us your attempt ( your code ) so we can get a better understanding as to where you went astray. Thanks and happy coding. https://www.sololearn.com/discuss/1316935/?ref=app
6th Dec 2020, 4:13 AM
BroFar
BroFar - avatar
+ 1
You can also use max() print( max( input().split() or [ "Hello", "worlds" ], key = len ) )
6th Dec 2020, 4:41 AM
Ipang
0
How does the "key=len" part fit in to all of this? That part is completly new to me
16th Dec 2020, 5:37 AM
Marco Duhaney
Marco Duhaney - avatar