Advertisement
Rayk

Inventory

Jul 13th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. items = input().split(', ')
  2.  
  3. while True:
  4. command = input()
  5. if command == 'Craft!':
  6. print(f'{", ".join(items)}')
  7. break
  8.  
  9. tokens = command.split(' - ')
  10. if tokens[0] == 'Collect':
  11. item = tokens[1]
  12. if item not in items:
  13. items.append(item)
  14. elif tokens[0] == 'Drop':
  15. item = tokens[1]
  16. if item in items:
  17. items.remove(item)
  18. elif tokens[0] == 'Combine Items':
  19. args = tokens[1].split(':')
  20. old_item = args[0]
  21. new_item = args[1]
  22. if old_item in items:
  23. index = items.index(old_item) + 1
  24. items.insert(index, new_item)
  25. elif tokens[0] == 'Renew':
  26. item = tokens[1]
  27. if item in items:
  28. current_item = item
  29. items.remove(item)
  30. items.append(current_item)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement