Advertisement
Guest User

Untitled

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