为什么Python在使用`==`与比较运算符组合时总是说无效语法,例如。 <, >等等?

问题描述 投票:0回答:2

这是我的代码:

age=int(input("what is the age of your dog?"))
if age == > 2
(age-2)+(age*4)+22

由于比较运算符“>”,我在第 2 行收到无效语法错误。

我已经尝试添加缺少的括号',但它没有帮助。

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

a==b
这意味着
a
b

相同

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

因此,如果

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

这在Python中是无效的

==>


-2
投票

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

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