[Tutor] Unexpected name error
dn
PythonList at DancesWithMice.info
Sun Jun 25 18:32:08 EDT 2023
On 25/06/2023 18.20, Jack Simpson wrote:
> 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
Additionally, (info missing) was x given a value before the if-construct?
--
Regards,
=dn
More information about the Tutor
mailing list