0

Which code outputs the user's longest word input

Using no shortcuts

4th Nov 2020, 9:55 AM
NIGHT LIGHT
4 ответов
+ 2
Both
4th Nov 2020, 10:20 AM
Abhay
Abhay - avatar
0
print(sorted(input().split(' '), key = lambda x: -len(x))[0])
4th Nov 2020, 9:59 AM
NIGHT LIGHT
0
Or sentence = input("Enter sentence: ") # Finding longest word longest = max(sentence.split(), key=len) # Displaying longest word print("Longest word is: ", longest) print("And its length is: ", len(longest))
4th Nov 2020, 10:02 AM
NIGHT LIGHT
0
txt = input() print(max(txt.split(),key=len)) Easy using Python
18th Dec 2020, 5:13 PM
Sudo
Sudo - avatar