jeudi 29 avril 2021

How to check two conditions for one variable?

Very basic issue that I do not understand:
My variable step has be 1 or 5 and I want to check it with if statement, and raise an error if the condition is not verified.

step = input("Choose a step, in nm, for the wavelength (1 or 5):")
if (
        (step != 1) or (step != 5)
):
    raise ValueError

But if I declare 1 or 5 for step I end with a ValueError.

I tried to do the thing in reverse, checking if step is equal to 1 or 5 but without success. And also with the if ... not in but no success to.

I am sure this is a very basic little thing but I don't see it.

Thanks for help

Aucun commentaire:

Enregistrer un commentaire