6

Good afternoon,

I am developing a script in python and while I am trying to compile it from the terminator/terminal i always get this error, but I cannot understand where is the syntax error?

File "_case1.py", line 128

print ('########################')
    ^

SyntaxError: invalid syntax

Then I just change the position of the sentence and what I get is..

print '########################'
    ^

SyntaxError: invalid syntax

What is the problem?

Jens
  • 67,715
  • 15
  • 98
  • 113
KChris
  • 63
  • 1
  • 1
  • 6

1 Answers1

5

Check the code before the print line for errors. This can be caused by an error in a previous line; for example:

def x():
    y = [
    print "hello"
x()

This produces the following error:

  File "E:\Python\test.py", line 14
    print "hello"
        ^
SyntaxError: invalid syntax

When clearly the error is in the line before it, y = [. It's tough to debug without more code, but if you have some brackets missing before the print line or something similar it can cause such an error.

maccartm
  • 2,035
  • 14
  • 23