I'm brand new to Python. Why does the below always resolve true (i.e. satisfy the if statement).
I have found a solution by putting brackets around the or part (also below), but I don't know why the solution works. Grateful for your advice! Thank you in advance.
problem code:
animals = ['dog', 'cat', 'mouse', 'shark']
if 'fox' or 'fish' in animals:
print('you found a new pet')
else:
print('you don\'t deserve a pet.')
solution code:
animals = ['dog', 'cat', 'mouse', 'shark']
if ('fox' or 'fish') in animals:
print('you found a new pet')
else:
print('you don\'t deserve a pet.')