def shop(total_spend): min_spend=25 discount_amount=150 discount=0.05 if total_spend >= min_spend and total_spend > discount_amount: checkout=total_spend-(total_spend*discount) discount=total_spend*discount else: checkout = total_spend discount = 0 return checkout def main(): spend = input('Enter the amount you spent: ') while spend<25: print "Error, min spend is €25 in this shop!" spend = input('Enter the amount you spent: ') else: total = shop(spend) print 'Your bill comes to',total,"\n","your discount was",discount main () #program works but how would i show the discount in main? I saved as text file in notepad........! Many thanks!!!!!!!!
# -*- coding: cp1252 -*- def shop(total_spend): min_spend=25 discount_amount=150 discount=0.05 if total_spend >= min_spend and total_spend > discount_amount: checkout=total_spend-(total_spend*discount) discount=total_spend*discount else: checkout = total_spend discount = 0 return checkout def main(): spend = input('Enter the amount you spent: ') while spend<25: print "Error, min spend is 25 in this shop!" spend = input('Enter the amount you spent: ') else: total = shop(spend) print 'Your bill comes to',total,"\n","your discount was",discount main ()
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor