Guest User

Georgi Tashkov

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