My sell function redirects to index, and I am able to see the correct stock prices and total value amounts formatted as USD, but for some reason check50 won't pass me on the final test (https://cs50.me/checks/f7c356884025daa03aebbe91edd59db9cafc4c27)

As suggested by the approved answer in pset7 finance check50 doesn't detect a valid sale despite portfolio updating correctly, I tried adding the following lines to lookup():

if symbol == "AAAA":
    return {"name": "Test A", "price": 28.00, "symbol": "AAAA"}

After doing this, I created a new account, bought 4 shares of 'AAAA', and sold 2 of them. As expected, index displayed $56.00 worth of shares and a cash balance of $9,944.00. So, I'm perplexed as to why I'm still failing check50. I also tried the suggestion of removing indexes from my database, but to no avail.

Update: Solved (see curiouswiki's answer)

  • Are you using usd for turning the 56 into "$56.00", like {{ price | usd }} in the template or usd(price) in Python? I forgot that in exactly one spot, and it was the one that got tested.
    – Blauelf
    May 16, 2019 at 16:32
  • I'll get someone to look at your submission to be sure there's no bug in check50.
    – curiouskiwi
    May 16, 2019 at 18:44
  • @Blauelf yes... still fails
    – ian_b
    May 16, 2019 at 18:56
  • @curiouskiwi Thank you! Much appreciated!
    – ian_b
    May 16, 2019 at 18:56
  • oops, you posted another persons check50 result... I think yours is cs50.me/checks/f7c356884025daa03aebbe91edd59db9cafc4c27 ? Someone's checking now.
    – curiouskiwi
    May 16, 2019 at 19:06

1 Answer 1


After reviewing your actual code

/sell needs to accept a POST request where shares is a number of shares, and symbol is a stock symbol. Your code has /sell take symbol as the ID of a row in a table called symbols

So that’s throwing things off. check50 is sending a payload like {"shares": 2, "symbol": "AAAA"}, but you are asking for something like {"shares": 2, "symbol": 28}

  • @curiouswiki Thank you, this worked! Thanks so much for looking into it.
    – ian_b
    May 16, 2019 at 20:06

You must log in to answer this question.

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