Sichanov

ss

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