为什么 python 总是说无效语法,尤其是在使用比较运算符时,例如。 <, >等等

问题描述 投票:0回答:2
age=int(input("what is the age of your dog?"))
if age == > 2
(age-2)+(age*4)+22

这是我的代码,但由于比较运算符“>”,我在第 2 行收到无效语法错误。 我已经尝试添加缺少的括号',但它没有帮助 请帮忙。

python-3.x comparison-operators
2个回答
0
投票

a==b
这意味着
a
b

相同

a=>b
表示
a
大于或等于
b

因此,如果

a
更大,则条件成立, 或者如果
a
等于
b
那么条件也成立。

这在Python中是无效的

==>


0
投票

=> 在 Python 中不起作用。应该>=。

© www.soinside.com 2019 - 2024. All rights reserved.