-1
执行一个程序,请求用户输入三个单词(字符串)。如果单词按字母顺序输入,您的程序应打印True
;否则没有打印。比较排序列表
Enter first word: bass
Enter second word: salmon
Enter third word: whitefish
True
由于B > S > W
,它打印True
这是我到目前为止有:
FirstWords=input("Enter first word: ")
SecondWords=input("Enter second word: ")
ThirdWords=input("Enter third word: ")
word=[FirstWords,SecondWords,ThirdWords]
print(word)
k=word.sort()
print(k)
if (k==None):
print('True')
elif (word==k):
print("True")
不知怎的,我不能word.sort()的值存储在K
相关:http://stackoverflow.com/questions/7301110/why-does-return-list-sort-return-none-not-the-list – NightShadeQueen
'list.sort'就地排序列表并返回'没有' – NightShadeQueen