Advertisement
Talithacelin

Voucher code

Oct 4th, 2022
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. import sys
  2.  
  3. def voucher(discount):
  4.     if havecode == "yes" or havecode == "Yes":
  5.         code = input("Enter voucher code : ")
  6.  
  7.         if code == "20%OFFYESPLS" or code == "GIMME20%OFF":
  8.             discount = total_order * 20/100
  9.             pay = total_order - discount
  10.             print("Congrats! You got a 20% discount!")
  11.             print()
  12.             print("Final total...$" , pay)
  13.             print("THANKS")
  14.             sys.exit()
  15.  
  16.         else:
  17.             print()
  18.             print("Sorry not a valid voucher.")
  19.             tryagain = input("Would you like to re-input? ")
  20.             if tryagain == "yes" or tryagain == "Yes" :
  21.                 voucher(discount)
  22.             else :
  23.                 novoucher()
  24.             print()
  25.             novoucher()
  26.             return tryagain
  27.     else:
  28.         novoucher()
  29.  
  30. def novoucher ():
  31.     if int(total_order) > 100 :
  32.         discount = total_order * 10/100
  33.         pay = total_order - discount
  34.         print()
  35.         print("For purchase above $100. You got a 10% discount")
  36.         print("and a free tea!")
  37.        
  38.         print()
  39.         print("Final total...$" , pay)
  40.         print("THANKS")
  41.         sys.exit()
  42.         return discount
  43.        
  44.     else :
  45.         print("Final total...$" , total_order)
  46.  
  47.  
  48. total_order = int(input("Enter total order: $"))
  49. havecode = input("Use a voucher code? ")
  50.  
  51. if havecode == "yes" or havecode =="Yes":
  52.     voucher(20)
  53.  
  54. else :
  55.     novoucher()
  56.  
  57.  
  58. #Talice~
  59.  
  60.  
  61.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement