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])
5 Antworten
+ 5
Harjot Singh
I believe the code is working fine! So where you are having issue in understanding?
+ 2
First show your attempt here
+ 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
+ 1
You can also use max()
print( max( input().split() or [ "Hello", "worlds" ], key = len ) )
0
How does the "key=len" part fit in to all of this? That part is completly new to me