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 ninja.inventory.remove("dog")
.
Swipe to start coding
Solution
Explore other courses in Catalog
Thanks for your feedback!
ninja.py
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Summarize this chapter
Explain the code in file
Explain why file doesn't solve the task
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 ninja.inventory.remove("dog")
.
Swipe to start coding
Solution
Explore other courses in Catalog
Thanks for your feedback!
Awesome!
Completion rate improved to 2.94ninja.py