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