how Given a text as input, find and output the longest word?

Question:

which one method I use for input front variable longest ?
txt = input()
Given a text as input, find and output the longest word.

Finding longest word

longest =

Displaying longest word

print(longest)

Answers:

I think this way is worked!!

txt = input()

Finding longest word

longest = max(txt.split(), key=len)

Displaying longest word

print(longest)

#or you can solve this solution an another way!!

longest = max(txt.split(), key=len)

Answered By: Hediye_seza
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.