Advertisement
svephoto

Tourist Shop [Python]

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