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"))
Created at: 2023/09/28 11:43; Updated at: 2023/09/29 07:13