Advertisement
fumanbest

Tourist Shop

Dec 24th, 2019
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. budget = float(input())
  2. budget_1 = budget
  3. product_counter = 0
  4. product_price = 0
  5. while budget_1 > 0:
  6.     text = input()
  7.     if text == 'Stop':
  8.         print(f"You bought {product_counter} products for {product_price:.2f} leva.")
  9.         break
  10.     else:
  11.         price = float(input())
  12.         if price > budget_1:
  13.             needed = price - budget_1
  14.             print("You don't have enough money!")
  15.             print(f"You need {needed:.2f} leva!")
  16.             break
  17.         else:
  18.             product_counter += 1
  19.             if product_counter % 3 == 0:
  20.                 price /= 2
  21.             product_price += price
  22.             budget_1 -= price
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement