[Tutor] Unexpected name error

Alan Gauld alan.gauld at yahoo.co.uk
Sun Jun 25 03:51:44 EDT 2023


On 25/06/2023 07: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)

You need to put quote signs around the thing you want to print.

Without quotes Python tries to evaluate the contents of the
brackets as code and since there is no variable called x it
gives a name error.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos





More information about the Tutor mailing list