0
I need help to complete a test
Good morning community, I need your help to be able to solve a Python test. They ask me to extract the longest word from a text with the "split()" method, I use it with the "max()" method but from all the text I only get two letters. I don't know how to fix it anymore.
3 Answers
+ 4
Please show your code.
Hint:
max() has a key parameter.
+ 2
Check the split-function: You split at double white spaces, not on single white spaces.
Either loop through the list to find the longest word or use the key parameter of max()
https://www.geeksforgeeks.org/JUMP_LINK__&&__python__&&__JUMP_LINK-longest-string-in-list/
0
txt = input()
#tu cĂłdigo va aquĂ:
text = txt.split(' ')
text1 = max(text)
print(text1)