Removing item by value
Previously, we removed items from the inventory by index, but itβs also possible to remove items from the inventory by value.
The inventory can contain objects like cat, dog, monkey, chicken, parrot, etc. So, if you want to remove dog from the inventory, you can simply write knight.inventory.remove("dog").
Swipe to start coding
Solution
Thanks for your feedback!
knight.py
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
How do I check if an item exists in the inventory before removing it?
What happens if I try to remove an item that isn't in the inventory?
Can you show me how to remove multiple items by value?
Awesome!
Completion rate improved to 2.94
Removing item by value
Swipe to show menu
Previously, we removed items from the inventory by index, but itβs also possible to remove items from the inventory by value.
The inventory can contain objects like cat, dog, monkey, chicken, parrot, etc. So, if you want to remove dog from the inventory, you can simply write knight.inventory.remove("dog").
Swipe to start coding
Solution
Thanks for your feedback!
knight.py