簡體   English   中英

SyntaxError:無效的語法,python3

[英]SyntaxError: invalid syntax, python3

income=float(input("enter the annual income: ")

if income<85528:
  tax=(income-556.02)*0.18
else:
  tax=(income-85528)*0.32+14839.02

tax=round(tax,0)
print("the tax is: ", tax, "thalers")

為什么它總是在第 2 行給出錯誤?

您在第一行缺少括號:“)”。 它可以通過以下方式修復:

income = float(input("enter the annual income: "))

完整程序:

income = float(input("enter the annual income: "))

if income < 85528:
    tax = (income - 556.02) * 0.18
else:
    tax = (income - 85528) * 0.32 + 14839.02

tax = round(tax, 0)
print("the tax is: ", tax, "thalers")

回報:

enter the annual income: 435
the tax is:  -22.0 thalers

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM