-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