This question already has an answer here:
- Python: False vs 0 3 answers
I'm trying to configure the following if else :
Basically 0 is equals to False in Python...
I would like to understand why this happens and how I can workaround in this case :
x=0
if x==False:
print "x == False" #always prints this line
elif x == 0:
print "x == 0"
Appreciate the help:
EDIT:
already tried
x = int(0)
Aucun commentaire:
Enregistrer un commentaire