简体   繁体   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")

Why does it keep giving an error on line 2?为什么它总是在第 2 行给出错误?

You have a lacking parenthesis in the 1st line: ")".您在第一行缺少括号:“)”。 It can be fixed by:它可以通过以下方式修复:

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

Complete program:完整程序:

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")

Returns:回报:

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