+ 1
What's the difference
I've seen some codes whereby true or false is interchanged using the values 1 and 0. Mostly i get confused as to what answer i must choose, so i just want clarity maybe with a code example of how to differentiate between the two
1 ответ
+ 1
# Standard is using True False keywords, if it is in language, rather than 1 or 0
# python
x = 10
print (x == x)        # True
# but some times is useful use 0 for false
a = "variable x = "      #not empty string
b = ""                             # empty string
if ( len(a) ):
    x = x+1
    print(a + str(x) )        # print it
if ( len(b) ):             # print nothing, because length b is 0    (and 0 is evaluated as False)
    x = x+1
    print(b + str(x) )
print( x )                  # 11




