0
Which code outputs the user's longest word input
Using no shortcuts
4 odpowiedzi
+ 2
Both
0
print(sorted(input().split(' '), key = lambda x: -len(x))[0])
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))
0
txt = input()
print(max(txt.split(),key=len))
Easy using Python