mardi 3 juillet 2018

How to code a test a statement with three or more components

Excuse me for the use of the term "component", there probably is a better term to use in such context.

But moving on to my question, I want to use the else statement to execute a statement block based on the truth of the test statement. Here is the test statement I tried using:

else:
   if ((reply != a) && (reply != c) && (reply =! e)):

I'm getting a syntax error, and the carrot is pointing at the first set of ampersands. I'm assuming now that I might be improperly using '&&'.

With this statement, my goal is to execute the statement block only if the test statement is true, meaning further, that 'reply' must not be equal to a, c, or e.

I know that I can use nested if's under the else statement, but I'm hoping StackExchange knows a better way. Thank you.

Aucun commentaire:

Enregistrer un commentaire