最长单词2

所属作业: hw5 算法: 循环

提示:

切除最后的句号用sentence[:-1]

1
2
3
4
5
6
7
8
sentence = input()
sentence = sentence[:-1]     # 切除最后的句号
words = sentence.split()     # 默认用空格切
longest_word = ""
for word in words:
    if len(word) > len(longest_word):
         longest_word = word
print(longest_word)