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