Given the following dict
CV = { a: [a, b], b: [b, c], c: [c], d: [d] }
Let's say I am lazy and I want to have the dictionary return a value that references the key, something like
CV = { a: [a, b], b: [b, c], _: [_] }
Is this possible?
Given the following dict
CV = { a: [a, b], b: [b, c], c: [c], d: [d] }
Let's say I am lazy and I want to have the dictionary return a value that references the key, something like
CV = { a: [a, b], b: [b, c], _: [_] }
Is this possible?
Use the .get()
method and set the key as the default values as well:
>>> my_dict = {"a": [1], "b": [2]}
>>> my_dict.get("a", ["a"])
[1]
>>> my_dict.get("c", ["c"])
['c']
>>>