0

I am on pset 7 and my quote function is throwing me a syntax error on else. Anyone can detect it? I know that an error where it is obvious mean that the lines before might be errorneous, but I can't find it:

def quote():
    if request.method == "POST":
        stock = request.form.get("stock")
        if lookup(stock) is not None:
            return apology("Stock", "not found")
        else:
            stock_info = lookup(stock)
            return render_template("quoted.html", stock = stock_info)
    """Get stock quote."""
    else:
        return render_template("quote.html")

The last else is throwing a syntax error. Thank you for anyone can help me.

1

You use a string literal """Get stock quote.""" as a comment. That one, as it's on the same indentation level as the if, breaks the if block, but it's not an else keyword, so when eventually finding that else: on the next line, interpreter does not know which if this should belong to.

Move your "comment".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .