DiYane

Vacation 3/10

Aug 14th, 2021
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. money_needed = float(input())
  2. money_owned =float(input())
  3.  
  4. days_cnt = 0
  5. spendeing_cnt = 0
  6.  
  7. while money_owned < money_needed and spendeing_cnt < 5:
  8.     command = input()
  9.     money = float(input())
  10.     days_cnt +=1
  11.  
  12.     if command == 'save':
  13.         money_owned += money
  14.         spendeing_cnt = 0
  15.     elif command == 'spend':
  16.         money_owned -= money
  17.         spendeing_cnt +=1
  18.         if money_owned < 0:
  19.             money_owned = 0
  20.  
  21. if spendeing_cnt == 5:
  22.     print('You can\'t save the money.')
  23.     print(days_cnt)
  24.  
  25. if money_owned >= money_needed:
  26.     print(f'You saved the money for {days_cnt} days.')
Advertisement
Add Comment
Please, Sign In to add comment