[英]Why am I getting “IndentationError: expected an indented block” here?
[英]Why am I getting an IndentationError when my code is properly indented?
以下是我的整個代碼。 在嘗試執行它時,我不斷收到錯誤消息
File "/Users/thomas/prac.py", line 15
elif choice == "1":
IndentationError: expected an indented block
現在我確定我的縮進是正確的(我沒有混合標簽和空格!)但我不知道為什么這不起作用:
keepProgramRunning = True
while keepProgramRunning:
print "Pleases choose an option: "
print "0"
print "1"
choice = raw_input()
if choice == "0":
#do something
elif choice == "1":
print "Bye"
keepProgramRunning = False
else:
print "try again"
怎么了?
評論不足以被視為縮進。 如果你想要一個空塊,那么你需要使用pass
語句。
你不能有空的if語句。 Python期望有一些東西存在於那里,如果你真的不需要放任何東西你可以放在那里。
但是為什么如果你沒有任何事情可以使用if語句。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.