Advertisement
veronikaaa86

03. Vacation

Oct 9th, 2022 (edited)
1,236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. needed_money = float(input())
  2. init_money = float(input())
  3.  
  4. count_spend_days = 0
  5. count_total_days = 0
  6. total_sum = init_money
  7. while total_sum < needed_money:
  8.     if count_spend_days == 5:
  9.         break
  10.     action = input()
  11.     amount = float(input())
  12.  
  13.     count_total_days = count_total_days + 1
  14.  
  15.     if action == "spend":
  16.         count_spend_days = count_spend_days + 1
  17.         total_sum = total_sum - amount
  18.         if total_sum < 0:
  19.             total_sum = 0
  20.     elif action == "save":
  21.         count_spend_days = 0
  22.         total_sum = total_sum + amount
  23.  
  24. if count_spend_days == 5:
  25.     print("You can't save the money.")
  26.     print(count_total_days)
  27. else:
  28.     print(f"You saved the money for {count_total_days} days.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement