我試過尋找答案,但似乎沒有任何幫助。我已經完成:如果String中沒有字符是Python中的元音,則返回True
def noVowel(s):
'return True if string s contains no vowel, False otherwise'
for char in s:
if char.lower() not in 'aeiou':
return True
else:
return False
無論字符串,它總是返回True。
好吧,我敢打賭,如果你在字符串中傳入'a',它會返回'False',因爲你總是在第一個字符後面返回(並且從不檢查其他字符)。 – nneonneo