• ask question

Question related to mission The Longest Word

 

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