Sichanov

evaaaaa

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