I have a simple code below that doesn't seem to output the expected result. The code only prints yup
once even though I expect the code to print yup
three times since that boolean expression will be true three times during the entire for loop iteration. Any advice on how to change my bool expression so that the loop prints yup
three times?
a1=['555','666','777',66]
b1=['999','888','333',66]
for a,b in zip(a1,b1):
if a == ('555' or '666' or 66):
print('yup')
maybe this helps highlight your problem
x = ('555' or '666' or 66)
print(x)
a1=['555','666','777',66]
for a in a1:
if a == x:
print("yup")
the correct check is
either
if a in ('555' or '666' or 66)
or
if a == '555' or a == '666' or a == 66