Advertisement
Guest User

Untitled

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