Python介绍,if语句。语法无效

问题描述:

大家好,我在这里新来的新的python。我正在研究一些我在网上发现的Python练习,并且被困在我做错了什么的地方。我正在努力学习和自我介绍if和else语句。这是我的代码。Python介绍,if语句。语法无效

weight = (float(input("How much does your suitcase weigh? ")) 
if weight > 50: 
      print("There is a $25 fee for a luggage that heavy.") 

print("Thank you for your buisness. ") 

input() 

我在50后得到一个无效的语法错误:不知道为什么。任何人都可以简单解释我做错了什么?

谢谢你的时间。

在您的第一行上,您缺少一个结束括号。

weight = (float(input("How much doees your suitcase weigh? "))) 
if weight > 50 : 
    print("There is a $25 fee for a luggage that heavy.") 

print("Thank you for your buisness. ") 

input() 
+0

嗯,这是很有意义的。这工作,我明白的地方我搞砸了。谢谢! – Matticus

+0

@Matticus提示:如果你在一条看起来很好的线上发现错误,通常意味着你错过了上面一行的括号,如果它解决了你的问题,接受这个答案。 – Carcigenicate

+0

感谢您的提示,哎呀没有意识到这是检查的目的。 – Matticus

解决方案是正确的...而且您实际上有额外的括号。

此代码也可以工作:

weight = float(input("How much does your suitcase weigh? ")) 

if weight > 50: 
    print("There is a $25 fee for a luggage that heavy.") 

print("Thank you for your business") 

你需要了解你开什么任何编程语言

/右括号。

weight = (float(input( 

现在你有三个(((所以在最后,你需要三个括号太

weigh? ")))