requested_toppings = ['mushrooms','green peppers','extra cheese']
for requested_topping in requested_toppings:
if requested_topping == 'green peppers':
print("Sorry,we are out of green peppers right now.")
else:
print(f"Adding {requested_topping}.")
print("\nFinished making your pizza!")
請問這個哪里有錯?????
報錯如下:
[Decode error - output not utf-8]
else:
^
IndentationError: unindent does not match any outer indentation level
[Finished in 0.1s with exit code 1]
uj5u.com熱心網友回復:
if 要縮進,print也要縮進uj5u.com熱心網友回復:
這么明顯的錯誤看不出來,報錯資訊都寫得很明確了。下面的那個 else 應該與上面的那個 if 對齊
也就是你語法的縮進錯誤。
uj5u.com熱心網友回復:
縮進錯誤,出現在else處else要跟if對齊
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/195462.html
上一篇:求大佬幫解決一下安裝問題
