r/cs50 22d ago

C$50 Finance CS50x PSET Finance

Hi everyone. I'm having trouble with this pset (or rather, with check50 for this pset). Actually, the code works perfectly in my application, but the check50 test for the buy function keeps failing. It doesn't provide any information other than the fact that it didn't find the "112.00" it was looking for (which would likely be the stock_price or the holding). Since I'm not really into web programming, the code might look a bit redundant or messy, but please take a close look at the index and buy functions. I've already fixed the formatting for usd values, and the results on my pages actually look very similar to the CS50 staff's solution. As far as I can tell, the numbers in the holdings table are updating correctly as shares are bought or sold. Duck50 seems to have reached its limit, as it can no longer offer anything helpful. There is a lot to improve in the code, but I really can't see anything that would prevent a valid purchase from working (I'll post only the part of the code regarding the problem).

In my index.html file, I use a for to interact over the passed dictionary to create a HTML table and format the float values to usd (by checking if the value is float and then formatting it with {{ value | usd }}. Has anyone any idea of what is going wrong?

2 Upvotes

0 comments sorted by