Advertisement
Kamend1

Untitled

Jun 24th, 2023
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | Source Code | 0 0
  1. needed_vacation_money = float(input())
  2. available_money = float(input())
  3. number_days_total = 0
  4. number_days_spend = 0
  5.  
  6. while available_money < needed_vacation_money:
  7. type_action = input()
  8.  
  9. if type_action == "spend":
  10. action_amount = float(input())
  11. if available_money <= action_amount:
  12. number_days_spend += 1
  13. number_days_total += 1
  14. available_money = 0
  15. else:
  16. available_money -= action_amount
  17. number_days_spend += 1
  18. number_days_total += 1
  19. if number_days_spend == 5:
  20. print(f"You can't save the money.")
  21. print(f"{number_days_total}")
  22. break
  23.  
  24. elif type_action == "save":
  25. action_amount = float(input())
  26. difference = (needed_vacation_money - available_money)
  27. if difference >= action_amount:
  28. available_money += action_amount
  29. number_days_spend = 0
  30. number_days_total += 1
  31. else:
  32. number_days_total += 1
  33. print(f"You saved the money for {number_days_total} days.")
  34. break
  35. else:
  36. print(f"You saved the money for {number_days_total} days.")
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement