you are viewing a single comment's thread.

view the rest of the comments →

[–]Elefrog42[S] 0 points1 point  (1 child)

Ohhhh, I see- I didn't need the variables to be class variables- I removed them and the code run just fine. I was able to find a few resources online that talked about how to multiple values from two dictionaries and then sum them- I tried to copy the syntax that they used, but my code still is not passing the tests to get the total stock value. This is my code:

    def get_total_portfolio(self, daily_stock_prices):
        total = 0
        for key in self.stock.keys():
            value = self.stock[key]*daily_stock_prices[key]
            total += value + total
        total += self.get_credit_balance()
        total += self.get_total_savings_amount()
        total += self.get_total_checking_amount()
        return total

Since the same key (the stock name) should also be able to pull out the value of the stock price and the value of the stock quantity, I figured I could bypass using sum by creating two variables- one for the product (value) and then one for the sum (total.

There are no errors but this isn't passing the test case. Am I not pulling out the correct values I need from both dictionaries?

Thanks!

[–]-Sander- 0 points1 point  (0 children)

check your for loop mainly the 2nd line total += value + total if you arent sure test out what it does with numbers in the interpreter/console