So, I want to create a loop that will increase the cost of an item any given amount of times while also logging the total of cost of the instance. The issue is that whenever I execute the program the output seems to be more than it should be, and if I change the value of the variable cost
to 10, then it seems to go over slightly more than it should. Here's the code:
amount = 3
cost = 0
increase = 10
for i in range(amount):
cost += increase
increase += increase
total = cost
print(total)
When cost = 0
total becomes 70, when I think it should be 60, and then when cost = 10
total becomes 80 when I think it should be 90.
Any help would be appreciated- sorry for asking such a stupid question. It's probably a super simple fix.