I don't get it, sometimes this code works but then sometimes it gives this error message: Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: name 'total' is not defined. But then sometimes when I submit it gives me the 'Congratulations you finished this section!' and I get the correct answer for a total being 117.
Correct answer apparently:
By the way, I found out I then add total = 0 in from of total += stock[item] * price[item] and then erase it, the code magically works somehow.
Replace this line with your code. Code: for item in prices: total += stock[item] * prices[item] print total
I just need an explanation of whether my code is right or its the system playing mindgames.