[英]if statement giving errors when ran but not in idle
I making a if statement for my program and when it runs it gives an error.我为我的程序做了一个 if 语句,当它运行时它给出了一个错误。 This is my code:
这是我的代码:
if num1 = num2:
print('Equal')
when you compare in python its == not =当您在 python 中进行比较时,它 == 不是 =
Basically, you've mixed up thw two operaters.基本上,您已经混淆了两个操作员。 = is used for assignment(such as x = 5).
= 用于赋值(如 x = 5)。 == is used to compare two values(like comparing x == y).
== 用于比较两个值(如比较 x == y)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.