My program needs to output a list of names with three numbers corresponding to each name however I don’t know how to code this is there a way I could do it as a dictionary such as cat1 = {“james”:6, “bob”:3} but with three values for each key? Answer The value for each key can either be a set (distinct
Tag: key
How to get the index with the key in a dictionary?
I have the key of a python dictionary and I want to get the corresponding index in the dictionary. Suppose I have the following dictionary, Is there a combination of python functions so that I can get the index value of 1, given the key value ‘b’? I know it can be achieved with a loop or lambda (with a
Is it reasonable to use None as a dictionary key in Python?
None seems to work as a dictionary key, but I am wondering if that will just lead to trouble later. For example, this works: The actual data I am working with is educational standards. Every standard is associated with a content area. Some standards are also associated with content subareas. I would like to make a nested dictionary of the
Dictionary keys match on list; get key/value pair
In python… I have a list of elements ‘my_list’, and a dictionary ‘my_dict’ where some keys match in ‘my_list’. I would like to search the dictionary and retrieve key/value pairs for the keys matching the ‘my_list’ elements. I tried this… But it doesn’t do the job. Answer (I renamed list to my_list and dict to my_dict to avoid the conflict