Advertisement
PowerCell46

Vacation Python

Dec 18th, 2022
1,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. needed_money = float(input())
  2. current_money = float(input())
  3. action = str(input())
  4. current_sum = float(input())
  5. spend_counter = 0
  6. days_counter = 0
  7.  
  8. while True:
  9.     days_counter += 1
  10.  
  11.     if action == "save":
  12.         current_money += current_sum
  13.         spend_counter = 0
  14.         if current_money >= needed_money:
  15.             break
  16.     elif action == "spend":
  17.         current_money -= current_sum
  18.         if current_money < 0:
  19.             current_money = 0
  20.         spend_counter += 1
  21.         if spend_counter == 5:
  22.             print("You can't save the money.")
  23.             print(f'{days_counter}')
  24.             break
  25.     action = str(input())
  26.     current_sum = float(input())
  27.  
  28. if current_money >= needed_money:
  29.     print(f'You saved the money for {days_counter} days.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement