-2
我是Python新手,目前正在学习有关AND,OR,而不是运算符。以下是我编写的示例程序,用于了解这些操作员如何与if-else命令一起使用。在Python中使用AND运算符没有得到期望的输出
a=4
b=7
if a=="4" and b=="7":
print "Good work.. keep it up!"
else:
print "Find the problem and solve it!"
我得到的输出不是我所期望的。这是Find the problem and solve it!
。我不明白。由于我的条件(a == 4 nad b == 7)都满足,为什么我会得到else
输出?如果我将==
替换为!=
,我将获得Good work.. keep it up!
输出。
有人可以向我解释这个吗?
整数4的值不是字符串4'A = = 4和b == 7'将按预期工作 –