Hint for Remove a few thing Hint


#1

There is a hint for Remove a Few Things(Python Lists and Dictionaries):

You can use list functions with a list stored in a dictionary as follows:
dict_name['list_key'].list_function()
This should help you delete 'dagger' from the list of items stored under the 'backpack' key.

I've tried this:

backpack = ['xylophone', 'dagger', 'tent', 'bread loaf']
backpack['dagger'].list_function()

,but it doesn't work, showing an error:

Traceback (most recent call last):
 File "python", line 2, in <module>
TypeError: list indices must be integers, not str

Could someone explain me how should dict_name['list_key'].list_function() work, please?


#2

@rikitikitavi69: In fact the hint was abit unclear.
When we say:

dict_name['list_key'].list_function()


The term list_function() will just be any possible function that we can use to handle lists.
So far I haven't seen, nor used, any function called list_function(), unless I wrote it myself.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.