Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. needed_money = float(input())
  2. owned_money = float(input())
  3.  
  4. days_counter = 0
  5. spending_counter = 0
  6.  
  7. while owned_money < needed_money and spending_counter < 5:
  8.     command = input()
  9.     money = float(input())
  10.     days_counter += 1
  11.  
  12.     if command == 'Save':
  13.         owned_money += money
  14.         spending_counter = 0
  15.     elif command == 'Spend':
  16.         owned_money -= money
  17.         spending_counter += 1
  18.         if owned_money < 0:
  19.             owned_money = 0
  20.  
  21.  
  22. if spending_counter == 5:
  23.     print(f'You cannot save the money')
  24.     print(f'{days_counter}')
  25. if owned_money >= needed_money:
  26.     print(f"You saved the money for {days_counter} days.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement