Unexpected syntax error

I don’t know why but i get an syntax error in the except line saying invalid syntax and if i remove the line i get an EOF error
code:
import pyautogui

try:
while True:
x,y=pyautogui.position()
positionStr='x: ’ +str(x).rjust(4) + 'y: '+str(x).rjust(4)
except KeyboardInterrupt:
print(\n done)

Hi @anujkheria, I think you need to spend more time figuring out these errors on your own before asking for help. You can’t write code if you need to ask for help at every little syntax error, because you’ll be having a lot of syntax errors. Now, you’ve already narrowed down what line is causing it, so it’s just a matter of figuring out what character caused it.

You should also start posting your code and error outputs like this:

[code]
# your code here
[/code]

That makes it easier to read. Finally, this line of code is weird:

 positionStr='x: ’ +str(x).rjust(4) + 'y: '+str(x).rjust(4)

I’d check that your keyboard is setup right because you have a normal straight quote with ’ and also a typographic curly quote that no programmer should ever type right at 'x: ’ the end there.

A free service run by Zed A. Shaw for learncodethehardway.org.