Mar-25-2017, 10:33 AM
(This post was last modified: Mar-25-2017, 10:41 AM by Liquid_Ocelot.)
Larz+60 Just wondering how you would go about making it a return function instead of yield as my instructions don't mention anything about yield and I do not think we are up to that keyword yet
Awesome Thanks I have got it now :)
return n, tax, tax_rate, totalI tried changing yield into return but I get this error...
for n, tax, tax_rate, total in calculate_tax(my_price, 5, 26, 5): TypeError: 'int' object is not iterable
(Mar-25-2017, 10:33 AM)wavic Wrote:In [10]: def result(item, price): ...: for tax in range(5, 26, 5): ...: percentage = price * tax / 100 ...: print("{:>2}% tax on a {} costing ${:.2f} is ${:.2f}".format(tax, item, price, percentage)) ...: In [11]: result(item, price) 5% tax on a Cake costing $17.50 is $0.88 10% tax on a Cake costing $17.50 is $1.75 15% tax on a Cake costing $17.50 is $2.62 20% tax on a Cake costing $17.50 is $3.50 25% tax on a Cake costing $17.50 is $4.38
My prev. post was a hint how to generate the tax list and use each tax to calculate the percentage
Awesome Thanks I have got it now :)