Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # стоп: налични пари >= нужни пари
- # продължаваме: налични пари < нужни пари
- need_money = float(input()) # нужни пари
- current_money = float(input()) # налични пари
- count_spend_days = 0 # брой на дни, в които харчим
- count_days = 0 # брой на дните, в които или харчим или пестим
- while current_money < need_money:
- # извършвам действие (spend/save)
- action = input() # spend or save
- count_days += 1
- sum = float(input())
- if action == "spend":
- # харчи
- count_spend_days += 1
- current_money -= sum
- if current_money < 0:
- current_money = 0
- elif action == "save":
- # пести
- count_spend_days = 0
- current_money += sum
- # проверка дали 5 последователни дни харчи
- if count_spend_days == 5:
- print("You can't save the money.")
- print(count_days)
- break
- else: # наличните пари >= нужните пари
- print(f"You saved the money for {count_days} days.")
Advertisement
Add Comment
Please, Sign In to add comment