SyntaxError:语法无效,python3

时间:2020-06-10 11:46:51

标签: python python-3.x if-statement

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行上总是出现错误?

1 个答案:

答案 0 :(得分:3)

第一行中没有括号:“)”。它可以通过以下方式解决:

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
相关问题