When using Python, is it possible that a dict can have a value that is a list?
for example, a dictionary that will look like this (see KeyName3 values):
{ keyName1 : value1, keyName2: value2, keyName3: {val1, val2, val3} }
I already know that I can use 'defaultdict', however individual values ββ(understandably) are returned as a list.
The reason why I ask is because my code must be shared so that the caller can return the values ββof one key as an element (exactly the same as from the value of the key of the key), and not as a list (without specifying pop[0] list) - however, also extract a few values ββin the form of a list.
If not, then any suggestions would be welcome.
If someone can help, it will be great.
Thanks Advance,
Floor
* I am using Python 2.6, but I am writing scripts that should also be compatible with Python 3.0 +.
python dictionary list key-value
Paul kernaghan
source share