Advertisement
Guest User

Untitled

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