Teo_Yanchev

easter_shop_20-21-2019_exam

Jul 17th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. available_eggs = int(input())
  2.  
  3. total_sold = 0
  4. command = input()
  5. while command != "Close":
  6. action = command
  7. eggs_action = int(input())
  8.  
  9. if eggs_action > available_eggs and command == "Buy":
  10. print("Not enough eggs in store!")
  11. print(f"You can buy only {available_eggs}.")
  12. break
  13. if action == "Buy":
  14. total_sold += eggs_action
  15. available_eggs -= eggs_action
  16. else:
  17. available_eggs += eggs_action
  18. command = input()
  19. else:
  20. print("Store is closed!")
  21. print(f"{total_sold} eggs sold.")
Add Comment
Please, Sign In to add comment