0

Hello,

This if statement is always returning true and I cannot see why. Could you guys tell me why?

menu = input("Choose what you would like to do:\n\n1. Work out how far you will travel with a set time and speed\n2. Work out the speed you will need to travel to do a certain distance in a specific time.\nChoice: ")
if(int(menu) != 1 or int(menu) != 2):
    print("Error. Enter 1 or 2.")
    menu = input("Choose what you would like to do:\n\n1. Work out how far you will travel with a set time and speed\n2. Work out the speed you will need to travel to do a certain distance in a specific time.\nChoice: ")
3
Contributors
3
Replies
85
Views
3 Years
Discussion Span
Last Post by Gribouillis
0

As an exercise please deny the following statement:
There is a moment is every woman's life, when she wants to do something forbidden.

Just joking.

You wanted to write: n!=1 and n!=2

2

There is a moment is every woman's life, when she wants to do something forbidden.

Easy, the opposite is: Some women never want to do anything forbidden.

Another solution was

if int(menu) not in (1, 2):

Edited by Gribouillis

Votes + Comments
I didn't know you could do that even when I knew python well. Thank you :).
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.