+ 1
How to do calculations in dictionary
13 Réponses
+ 1
The origanalRevenue isn't actually 15000. I think it's 530 but i could be wrong.
I'd try that first and then maybe look over your for loop.
This is what I used. I can explain my code if you'd like
nya = 0
for x in data.values():
if x < age:
nya += 5
else:
nya += 20
0
Thanks I'll try.
0
Let me know how it goes
0
Ok
0
The if condition of your loop produces the wrong results
0
Thats strange. It works for me. Are you sure you've got the old revenue right now?
0
try using 16 and 10 as discounted age and if you get 5 and 33 respectively as percentage revenue growth then it means you are correct.
0
And please show your full code for me to see how you have worked out except for the dictionary collection
0
The reason why I'm saying you are wrong is your loop multiplies the next value in value list by twice the variable ticket cause of += sign
0
Try my code and compare with yours
0
#your code goes here
gamla = 0
for x in data.values():
if x < 18:
gamla += 5
else:
gamla += 20
nya = 0
for x in data.values():
if x < age:
nya += 5
else:
nya += 20
print(int(100 * (nya - gamla)/ gamla))
0
Your method works