I am new to python and I am looking for some help with loop structures, specifically how to use a 'For' loop or alternative loop to solve a problem. I need to figure a discounted price based on the previous days' discounted price in an array so it will iterate through the array an apply the 10% discount. Here is what I have so far:
opnDays = ["mon", "tue", "wed", "thr", "fri"]
price = 10
def discount(array):
for day in array:
disPrice = price - (price * .1)
print(day, disPrice)
discount(opnDays)
>>>
mon 9.0
tue 9.0
wed 9.0
thr 9.0
fri 9.0
I want to get:
>>>
mon 9.0
tue 8.1
wed 7.29
thr 6.561
fri 5.9109
Any help with how to organize this loop to get a the 10% discount from the previous day would be helpful. Thank you
price = price - (price * .1);print(day, price)