Everything was going fine and I refreshed the page to check my updates when I got an internal server error and the whole page didn't load. I looked in my IDE terminal and it said

File "/home/ubuntu/pset8/finance/application.py", line 87
    def buy():
SyntaxError: invalid syntax

The rest of my buy function worked fine, and I was working on showing the portfolio when this occurred. I did not touch this specific line, so I'm not sure why it suddenly doesn't work (and the other "def xxx():" seem to work fine.).

Any ideas?

  • I realized I hadn't added an "else:" to finish out my "if:". However, now the error is saying else: is the invalid syntax.
    – azb1297
    Feb 25, 2020 at 22:11
  • 2
    An else isn't required. Check the function before for imbalanced parens or " (or anything that needs a close to an open). Pay attention to the code that was updated before the error began. Feb 25, 2020 at 23:07
  • Got it! I had one random extra parenthesis. The devil is in the details.
    – azb1297
    Feb 26, 2020 at 5:01


You must log in to answer this question.

Browse other questions tagged .