It(should ,對我來說)如果在字符串(短語)中只有元音,則說True
;否則說False
。我不明白爲什麼它總是會返回False
,因爲(x> = x)總是返回True
。 我感謝任何人檢查此查詢的解決方案。爲什麼str.count('')≠(來自str.count('A')+ str.count('B')+ ... + str.count('Z'))
(STR) - > BOOL
def valid_letter_sequence(abc):
valid_letters = abc.count('A') + abc.count('E') + abc.count('I') + abc.count('O') + abc.count('U')
counted_letters = abc.count('')
if valid_letters >= counted_letters:
return True
else:
return False
當然,它更容易使用'LEN(ABC)'可惜不知道在'count'這個細節。您的評論當然是有用的,只要我獲得聲譽,就會投票給您。 我總是試圖縮短我的代碼,您的反饋肯定是有啓發性的。 謝謝。 –