a=999999
b=999999
if a is b:
print("yes")
else:
print("no")
The answer to the following code is no.
Why python is not able to compare a and b inspite of the fact that both the values are equal to 999999
a=999999
b=999999
if a is b:
print("yes")
else:
print("no")
The answer to the following code is no.
Why python is not able to compare a and b inspite of the fact that both the values are equal to 999999
The correct way to compare two values for equality is:
a == b
When you use is
, you're comparing object identity, not equality.
Try this...!
a=999999
b=999999
if a == b:
print("yes")
else:
print("no")
You are checking if the two variables are the same obect with is. You are most likely looking for ==
a == b