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)
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)
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)