When running a program such as the following, the first x, y definition is = even though it is one. Why are x and y after if written in ==?
x=0
y = 10
if x == 0 or y == 0:
print(" either x or y is 0")
The difference between substitution into variables and determining whether left and right are the same values.For more information, see Python tutorials and more.
When = is one, programming means to substitute the right side for the left side.
If you want to use math equal, use ==.
x = 0#x with 0
substitute 10 for y=10#y
# If x is 0 or y is 0, print "x or y is 0".
if x == 0 or y == 0:
print(" either x or y is 0")
© 2024 OneMinuteCode. All rights reserved.