I don't understand why the "or" operator is not working as intended in this case.
Here is the code:
fuel = input()
liters = float(input())
if fuel != 'Gas' or fuel != 'Diesel' or fuel != 'Gasoline':
print('Invalid fuel!')
else:
if liters >= 25:
if fuel == 'Gas' or fuel == 'Diesel' or fuel == 'Gasoline':
print(f'You have enough {fuel.lower()}.')
elif liters < 25:
if fuel == 'Gas' or fuel == 'Diesel' or fuel == 'Gasoline':
print(f'Fill your tank with {fuel.lower()}!')
Input:
Gas
25
Output:
Invalid fuel
The output should be You have enough gas.
When I change the operator to "and", the code works fine.
if fuel != 'Gas' and fuel != 'Diesel' and fuel != 'Gasoline':
print('Invalid fuel!')
Could someone please explain why is this happening?