Reputation: 731
I want my code increase in increments each time it loops but I am unsure how to do it.How to I get it to repeat itself while increasing by $10, 10 times.
This is what I have so far:
def money():
amount = float(input("Enter NZ convertion amount:$ "))
AUD = amount*0.96
US = amount*0.75
Euro = amount*0.67
GBP = amount*0.496
print('NZ$', amount,'AUD: {}, US:{}, Euro: {}, GBP: {}'.format(AUD, US, Euro, GBP))
return
money()
any ideas?
Upvotes: 0
Views: 38
Reputation: 3742
AUD = 0.96
US = 0.75
EUR = 0.67
GBP = 0.496
def money(delta, times):
amount = float(input("Enter NZ convertion amount:$ "))
for dta in range(times):
amt = amount + delta * dta
print('NZ$ {} AUD: {}, US:{}, Euro: {}, GBP: {}'.format(amt,
amt * AUD,
amt * US,
amt * EUR,
amt * GBP)
money(10.0, 10)
Upvotes: 1
Reputation: 13642
Why don't you simply wrap the calculation and printing part into a 10 times for loop like this?
def money():
amount_ = float(input("Enter NZ conversion amount:$ "))
for i in range(1, 11):
amount = amount_ * i
AUD = amount*0.96
US = amount*0.75
Euro = amount*0.67
GBP = amount*0.496
print('NZ$', amount,'AUD: {}, US:{}, Euro: {}, GBP: {}'.format(AUD, US, Euro, GBP))
return
Upvotes: 0