Regarding lesson “A Day at the Supermarket”
exercise 9 - Something of Value

total = 0
for k in prices:
print prices[k] * stock[k]
total = total + (prices[k] * stock[k])

why do I need the ( ) brackets? shouldn’t * always be calculted first than +.


Hi @valente5,

In fact, you do not need the parentheses here, due to the order of precedence of operations to which you alluded …

total = total + (prices[k] * stock[k])


ok, thanks… code academy wasn’t accepting it as a correct answer.


Are you sure that it was that line that Codecademy considered to be the issue? What message did you receive that indicated that there was a problem?


I don’t remember anymore… no worries, thanks for the help