Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 03. Vacation
- trip_cost = float(input())
- current_money = float(input())
- total_days = 0
- days_spending = 0
- while trip_cost > current_money and days_spending < 5:
- action = input()
- amount = float(input())
- total_days += 1
- if action == "spend":
- days_spending += 1
- current_money -= amount
- if current_money < 0:
- current_money = 0
- elif action == "save":
- current_money += amount
- days_spending = 0
- if trip_cost <= current_money:
- print(f"You saved the money for {total_days} days.")
- if days_spending == 5:
- print(f"You can't save the money.")
- print(total_days)
Advertisement
Add Comment
Please, Sign In to add comment