Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2021
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. budget = float(input())
  2. money_left = budget
  3. money_spent = 0
  4. product_counter = 0
  5. product_name = input()
  6.  
  7. while product_name != "Stop":
  8.     product_price = float(input())
  9.     product_counter += 1
  10.  
  11.     if product_counter % 3 == 0:
  12.         product_price *= 0.5
  13.  
  14.     if product_price > money_left:
  15.         money_needed = product_price - money_left
  16.         print("You don't have enough money!")
  17.         print(f'You need {money_needed:.2f} leva!')
  18.  
  19.     money_left -= product_price
  20.     money_spent += product_price
  21.     product_name = input()
  22.  
  23. if product_name == "Stop":
  24.     print(f'You bought {product_counter} products for {money_spent:.2f} leva.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement