Advertisement
bl00dt3ars

03. Vacation

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