我以爲一切都在這裏正確縮進,但我得到一個IndentationError:預計縮進塊在其他:聲明。我在這裏犯了一個明顯的錯誤嗎?Python:預期的縮進塊
def anti_vowel(text):
new_string = ""
vowels = "aeiou"
for letter in text:
for vowel in vowels:
if (lower(letter) == vowel):
#do nothing
else:
#append letter to the new string
new_string += letter
return new_string
空塊,你應該使用'pass'。 –
如果你已經知道你必須在'if'塊中加入一些東西,並認爲你有......評論不是一個聲明。最簡單的想法就好像在代碼被解析之前註釋被移除一樣。 – abarnert