Advertisement
ingram9999

Untitled

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