I’m getting an Assign Operator Error for the following code written this way:
for i in range(0,len(hairstyles)): prices[i] * last_week[i] += total_revenue
But there is no error when written this way:
for i in range(0,len(hairstyles)): total_revenue += prices [i] * last_week [i]
I found this explanation for a similar error in stack overflow:
When you use an assignment operator, you assign the value of what is on the right to the variable or element on the left. In your case, there is no variable or element on the left, but instead an interpreted value: you are trying to assign a value to something that isn’t a “container”.
So in the case the “operator” is “+=” and on the left there the interpreted value “i” which is not a “container”. Where as total_revenue is a container and therefore should be on the left-hand side?
Also, why is “i” an interpreted value and not a container?