vendredi 7 septembre 2018

Python OR condition not working with IF statement [duplicate]

This question already has an answer here:

My code is very simple and when I remove the conditional statement or then my code runs fine, like just searching for one location = 'united states' works but when I add the or statement it is making it true. I have tried two different methods but neither are working. Where am I making this simple mistake?

1st

location = 'united states'
if 'united states' or 'United States' not in location:
    print('some other location')
else:
    print('run some code')

2nd

location = 'united states'
if location != 'united states' or 'United States':
    print('some other location')
else:
    print('run some code')

Aucun commentaire:

Enregistrer un commentaire