0

My code was working just fine earlier today until I changed around a few libraries that I was using. Now, I'm getting this error when I try to run the code:

File "wimmer.py", line 29
category = raw_input('Give me a category: ')
       ^
SyntaxError: invalid syntax

I'm not quite sure what's wrong. Any suggestions?

Code: (the indentation is slightly off)

browser = Browser()

book = open_workbook(join('googleurls.xls'), formatting_info=True, on_demand=True)
testcell = book.sheet_by_index(0).cell(0,15).value
print ('The test link is: %s' % (testcell))
raw_input("Press ENTER to continue")



with book as myfile:

for i in range(0, 9):
    line = book.sheet_by_index(0).cell(i,15).value
    #for line in myfile:

    browser.visit(line)
    print ('The link is: %s' % (line)) 
    print ('The search term is: %s' % (myfile.cell(i, 0))
    #enter terminal prompts

    category = raw_input('Give me a category: ')
    print ('Your category was %s' % (category))
    #put this in the excel sheet in the right column

    fusion = raw_input('Fuse with another? ')
    print('Term was fused with %s' % (fusion))
    #put this in the excel sheet in the right column

    translate = raw_input('Change translation to -? ')
    print('Term was translated to %s' % (translate))
    #put this in the excel sheet in the right column

    raw_input("Press ENTER to continue") #moves onto next link
3
  • 8
    That line is fine. Check the one(s) above it for missing parenthesis/brackets/etc. Commented Nov 13, 2014 at 21:27
  • 1
    can you show the surrounding lines? Commented Nov 13, 2014 at 21:27
  • My comment to this question was soooo true ... Commented Nov 14, 2014 at 7:32

3 Answers 3

0

Often, when python (or another language) parses a file, and there is an error in the file, it will think the problem is on the line after - this is because it interprates the line with the error as the first part of the instruction, and the following line as the second part. The first part is ok (apart from being incomplete), but when it tries to read the next bit, it doesn't make sense (because it's supposed to be a separate instruction).

Check out the line(s) before, make sure all your brackets & braces line up.

Sign up to request clarification or add additional context in comments.

1 Comment

Great, thanks! It was a simple parentheses problem.
0

Your error is somewhere else in your program (likely a missing closing paren, or something similar, a few lines above).

For future reference, when asking "why is X a syntax error?", always supply us with the complete file that does result in the error.

Comments

0

Your line

print ('The search term is: %s' % (myfile.cell(i, 0))

is missing a final ). This is causing the syntax error. In the future, I highly recommend programming in an IDE/text editor that supports automatic bracket matching, so you don't have to worry about this type of thing.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.