1

Everything was working fine in this program I've been writing, and then out of nowhere I started getting all sorts of weird errors. For example:

    print Bounds[atomCounter][i][2]
    elif Bounds[atomCounter][i][2] == 'S':

Gives the error:

elif Bounds[atomCounter][i][2] == 'S':
   ^
SyntaxError: invalid syntax

It didn't give this error like ten minutes ago, and it doesn't unless the print statement is there. If the print statement isn't there, I get an index out of bounds error - but that shouldn't but the case, because the print statement works (just causes an error in the code after it)... anybody know what's wrong?

5
  • 3
    First guess is indentation error since before an elif you have to have an if and it needs to be indented, which your print does not appear to be. It'd be more helpful if you posted the whole if/elif block. Commented Jul 19, 2011 at 17:59
  • 2
    Another thing to check: ensure you don't have from __future__ import print_function at the top of the file. Commented Jul 19, 2011 at 18:01
  • do you have an "if" before the print ? :) Commented Jul 19, 2011 at 18:01
  • Voting the question +1 as compensation. Can't see why it was downvoted, and the downvoter hasn't left a comment explaining why (he should). Commented Jul 19, 2011 at 18:15
  • 1
    -1: Too little code to reason out what's wrong. Commented Jul 19, 2011 at 19:09

1 Answer 1

2

I don't know why you're using elif, but you can only do that after an if or another elif block. So of course that wouldn't work.

Since it looks like you might have an if block before what you've written, try indenting the print line and see if that works.

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

3 Comments

Oh wow, I thought this was a much bigger problem than that - thanks for the fast response.
@laplacian Accept the answer if it worked, if you don't mind.
Sorry I'm new to this - I thought I was probably supposed to do something like that, but couldn't find it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.