I receive the following error when I attempt to access the current cash from logged in user:
File "/home/ubuntu/workspace/pset7/finance/application.py", line 73, in buy if (price * shares) > cash['cash']: IndexError: list index out of range
The above error code is referring to: cash['cash'] . I obtain my value for variable cash with:
cash = db.execute("SELECT cash FROM users WHERE id = :user_id", user_id=session["user_id"])
I thought that you can access the money amount using cash[value][key]. If so, why am I out of range?
When I use the following code (print("cash=",cash) right after my db.execute statement, I get the following in terminal: cash= [ ].
Also, I have verified that the user who is logged in has cash (10000.00) in 'cash'.