0

Once again Python's helpful error messages make me eat my keyboard.
I've checked the whole script forwards and backwards but can't find any "syntax error(s)".

Is there a decent debugger for Python or a helpful website which is able to scan my code for errors?

C:\Users\Daapii\Desktop>"foo.py"
File "C:\Users\Daapii\Desktop\foo.py", line 26

print "test"


           ^

SyntaxError: invalid syntax

Python why u no tell me more!

Ankur Ankan
  • 2,953
  • 2
  • 23
  • 38

2 Answers2

8

If this is Python 3, then the print function now requires parenthesis. Try print("test").

(EDIT: If Python continues to make you want to eat your keyboard, this might help.)

Joe
  • 46,419
  • 33
  • 155
  • 245
  • 1
    And the user can figure out if it is Python3 by putting `import sys`, and `print (sys.version)` at the top of the program. – Robᵩ Sep 12 '13 at 13:43
  • thanks @all will try it out and report back :) and thanks for the chocolate keyboard link –  Sep 12 '13 at 13:46
  • 2
    +1 for working chocolate into your answer. – ron rothman Sep 12 '13 at 13:47
  • that did the trick, I'm quite new to python so I'm still struggling, thanks for your help! –  Sep 12 '13 at 14:05
  • @Joe: I think you used 'brackets' when you meant 'parenthesis'. – JS. Sep 12 '13 at 16:50
  • True, 'parentheses' always means `()` but brackets is a broader term that could include `()`, `[]`, `⟨⟩` etc. Maybe it's a British English vs American English thing? Either way, no reason for me not to edit my answer. – Joe Sep 12 '13 at 16:55
1

print is a function in Python 3:

print ("test") 

Find other changes here: docs

Paddyd
  • 1,870
  • 16
  • 26