Advertisement
Spocoman

Easter Shop

Feb 21st, 2022
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. available_eggs = int(input())
  2. sold_eggs = 0
  3.  
  4. command = input()
  5. while command != "Close":
  6.     eggs = int(input())
  7.     if command == "Buy":
  8.         if available_eggs - eggs < 0:
  9.             break
  10.         available_eggs -= eggs
  11.         sold_eggs += eggs
  12.     elif command == "Fill":
  13.         available_eggs += eggs
  14.  
  15.     command = input()
  16.  
  17. if command == "Close":
  18.     print("Store is closed!")
  19.     print(f"{sold_eggs} eggs sold.")
  20. else:
  21.     print("Not enough eggs in store!")
  22.     print(f"You can buy only {available_eggs}.")
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement