Home > Software engineering >  How can i have two not arguments in an if statement
How can i have two not arguments in an if statement

Time:12-04

I want to check if the following value is not a digit and is not "a" or "b" but I'm met with a syntax error. It says it expect ":" after not in the second argument.

if not char.isdigit() and not in ('a', 'b'):

I don't know what I can try to fix this. I could nest the if statement but that leads to bad code and I know there must be some solution.

CodePudding user response:

The line should be:

if not char.isdigit() and char not in ('a', 'b'):

You have to declare what variable is not in ('a', 'b')

Furthermore, I would take a look at how to structure questions on StackOverflow.

  • Related