Then .remove(‘dagger’) from the list of items stored under the ‘backpack’ key.
Question A- having problem in executing this question
Question B - What is the unique set of weight values mentioned in question number 4?
Question A- having problem in executing this question
Question B - What is the unique set of weight values mentioned in question number 4?
HI Tarun
Question A
Here in the question, you had a list dictionary that consists of key-value pairs. And value for the key backpack
is a list of values.
So you need to remove an item from the list of values of backpack
key by using .remove()
function.
for example :
arr = [1,2,3,4]
arr.remove(2)
# Here the element 2 will be removed from the `arr`
# arr = [1,3,4]
Similarly you have to remove from inventory['backpack"].remove('dagger')
Question B :
What is the unique set of weight values mentioned in question number 4?
Remember the set()
Data structure can give us a unique set of elements. So apply set over the list of elements so that you can have only a unique set of elements.
I hope I answered your questions if not please do reply
Thank you