-1
這是我的功能,我試圖用他們的第一個字符分隔整個單詞。例如,應該產生如「藍色,紅色」的「紅色,藍色」按優先級隊列上的排序順序排序
def isInAlphabeticalOrder(word):
word1=sorted(word)
return(word1)
print(isInAlphabeticalOrder("blue, yellow, green, red"))
它表明:
[' ', ' ', ' ', ',', ',', ',', 'b', 'd', 'e', 'e', 'e', 'e', 'e', 'g', 'l', 'l', 'l', 'n', 'o', 'r', 'r', 'u', 'w', 'y']
我想我的結果是這樣的;
("blue, green, red, yellow")
你應該分裂您輸入的字符串。或者你應該使用列表 –