Advertisement
Darlexbg

Fix for exercise 3. Vacation

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