[Tutor] Unexpected name error

Jack Simpson simpsonrmz41 at gmail.com
Sun Jun 25 02:20:15 EDT 2023


Hi,

I am playing around with the if, elif, else statements and can't figure out
why I am getting this name error when I have defined the value of x. Any
pointers would be great.

>>> if x>7:
...  print(x is positive)
... elif x>12:
...  print(x is negative)
... else:
...  print(x is str(0))
...  x=15
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined


More information about the Tutor mailing list