Advertisement
Yashov

Untitled

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