I am working on pset9 finance and I have been stuck for a while on it, especially this part:
cash = db.execute("SELECT cash FROM users WHERE user_id = :userid", userid=
session["user_id"])[0]["cash"]
price = lookup(request.form.get("symbol"))['price']
shares = float(request.form.get("shares"))
symbol = request.form.get("symbol")
datenotstring = datetime.datetime.now()
date = datenotstring.strftime("%m/%d/%Y")
if price*shares > cash:
return apology("not enough money, can't afford", 400)
It crashes on cash = db.execute("SELECT cash FROM users WHERE user_id = :userid", userid= session["user_id"])[0]["cash"]
with the error cash = db.execute("SELECT cash FROM users WHERE user_id = :userid", userid = session["user_id"])[0]["cash"] IndexError: list index out of range
I am unsure of how to fix this, in register I had it add cash to the user's account and that worked fine. Please help. Thanks