From my understanding, and
is a short-circuit operator as explained in the doc. But, why the part c gets printed every I run the code below?
My solution: if ('RB' in t) and (not ',' in t): ...
, but what I want is an explanation.
test = '977'
if 'RB' and '+' in test:
print('a')
test = int(test.replace('RB+', '')) * 1000
elif ',' and 'RB' in test:
print('b')
temp_test = test.replace(',', '')
test = int(temp_test.replace('RB', '')) * 1000
elif 'RB' and not ',' in test:
print('c')
test = int(test.replace('RB', '')) * 1000
else:
test = int(test)
print(test)
Ouput
c
977000