I have this little python code, it doesn't work as below.
while True:
activity = input("What would you like to do today? ")
a="cinema"
b="tennis"
if a or b not in activity.lower():
print(f"Instead of {activity} I want to go to the cinema")
else:
print("Sure Let's do that!!")
However when I extract the or b
, it works fine
while True:
activity = input("What would you like to do today? ")
a="cinema"
b="tennis"
if a not in activity.lower():
print(f"Instead of {activity} I want to go to the cinema")
else:
print("Sure Let's do that!!")
The question is why doesn't a or b
doesn't when used with not in
work?
EDIT: I have done the below modification, But still doesn't work.
while True:
activity = input("What would you like to do today? ")
a="cinema"
b="tennis"
if (a not in activity.lower()) or (b not in activity.lower()):
print(f"Instead of {activity} I want to go to the cinema")
else:
print("Sure Let's do that!!")
Below link is also suggested for this post. It is also very good. So I share it for the ones who will benefit from