Hello stackoverflow Community :-)
I am learning Python at the moment and I don't understand the "True/False" concept entirely.
In Python the number 0 is associated to "False" and 1 to "True".
When I write following code
x = 2
y = 1
if y == True:
print("Y is True")
if x == True:
print("X is True")
else:
print("X is False")
I get "Y is True", because the "1" is truthy. And I get "X is false", but I thought that this should be also "True", because there is a value (x = 2) and not "None, 0, etc.."
When I write
if x:
print("X is True")
else:
print("X is False")
then I get "X is True", because x is not empty and thus truthy.
What is the exact difference between "if x:" and "if x == True"?