0

How to delete a certain object in a list if the list is a class method [Python]

So I am making a text RPG, and the player has a class. The class is named player, and has a method called inventory. If the player wants to sell something from their inventory, they can go to the shop to sell it. They specify what they want to sell (if it is in their inventory), and it gets removed from their inventory. My question is, how can I remove their choice from the list? If you need a better explanation, I can elaborate. Thanks!

9th Feb 2019, 1:24 AM
DrChicken24
DrChicken24 - avatar
3 ответов
+ 6
It is working fine for me. I have tried to implement it in a class. https://code.sololearn.com/ctB8J0Fn6aPk/?ref=app
9th Feb 2019, 2:11 AM
Arushi Singhania
Arushi Singhania - avatar
+ 5
You can do listname.remove(item) I have used it in this code https://code.sololearn.com/cK93ys1JiAOX/?ref=app
9th Feb 2019, 1:41 AM
Arushi Singhania
Arushi Singhania - avatar
0
@Arushi Singhania Thanks for answering. I've tried that already, but it comes out like this: player.inv.remove(sell_choice), and that doesn't work...
9th Feb 2019, 1:50 AM
DrChicken24
DrChicken24 - avatar