Advertisement
Guest User

Georgi Tashkov

a guest
Nov 29th, 2020
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. money_needed = float(input())
  2. money_balance = float(input())
  3. days = 0
  4. spend_days = 0
  5.  
  6. while True:
  7.     action = input()
  8.     money = float(input())
  9.     if action == "spend":
  10.         spend_days += 1
  11.         days += 1
  12.         if money <= money_balance:
  13.             money_balance -= money
  14.         elif money > money_balance:
  15.             money_balance = 0
  16.         if spend_days == 5:
  17.             print(f"You can't save the money.\n{days}")
  18.             break
  19.     elif action == "save":
  20.         spend_days -= spend_days
  21.         days += 1
  22.         money_balance += money
  23.     if money_balance >= money_needed:
  24.         print(f"You saved the money for {days} days.")
  25.         break
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement