3
votes

I'm really confused, I just wrote this

x = 0
y = 42

#Can also be written like this

x, y = 0, 42

print x
print y 

And copy pasted it into IDLE to test it (I'm trying to relearn python along PHP) and then typed "x" and it returned 0. I type y and it gives me an error that it's not defined. When I run this normally though it works fine. What's going on?

Here is the exact error:

Traceback (most recent call last): File "", line 1, in y NameError: name 'y' is not defined

1
Works correctly for me in IDLE 2.7 - Michael Berkowski
You might want to look at IdleX -- it handles this particular issue (at least for me on OS X). - DSM

1 Answers

2
votes

I think your problem might have to do with posting multiple lines of code into IDLE. Take a look at the following:

Pasting multiple lines into IDLE

Hope this helps!