Light Mode
Dark Mode
ask question

I have trouble with this task. It turns out that it works for me when I type it at the PyCharm or t Visual Studio Core, but I can not complete the mission successfully.

def longest_word(sentence: str) -> str:

    words = sentence.split()
    length=[]
    for i in range(len(words)):
        l=len(words[i])
        length.append(l)
    maXimum=max(length)
    poz=length.index(max(length))
    word=words[poz]

    return word



print("Example:")
print(longest_word("hello world"))
Attachment
Created: Sept. 28, 2023, 11:43 a.m.
Updated: Sept. 29, 2023, 7:13 a.m.
0
5
User avatar
MARINA_