BbJLeB

03. Vacation

May 15th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. # 03. Vacation
  2. trip_cost = float(input())
  3. current_money = float(input())
  4. total_days = 0
  5. days_spending = 0
  6.  
  7. while trip_cost > current_money and days_spending < 5:
  8.     action = input()
  9.     amount = float(input())
  10.  
  11.     total_days += 1
  12.     if action == "spend":
  13.         days_spending += 1
  14.         current_money -= amount
  15.         if current_money < 0:
  16.             current_money = 0
  17.  
  18.     elif action == "save":
  19.         current_money += amount
  20.         days_spending = 0
  21.  
  22. if trip_cost <= current_money:
  23.     print(f"You saved the money for {total_days} days.")
  24. if days_spending == 5:
  25.     print(f"You can't save the money.")
  26.     print(total_days)
Advertisement
Add Comment
Please, Sign In to add comment