jarod_v6--- via Tutor <[email protected]> writes:
> Hi!!I would like to prepare a dictionary with complex structure:
>
> complex = {name ="value",surname="po",age=poi)
That's invalid syntax (the braces don't match) and it seems to use names
from elsewhere.
If you mean a dictionary like this::
wibble = {'name': "value", 'surname': "po", 'age': 42}
then that is a simple dictionary. So I don't know what you mean by a
“complex” dictionary.
> What is the most pythonic way to build a dictionary of
> dictionary?
You can assign any value to any key in a dictionary. Dictionaries are
also values, so a dictionary can be assigned to a key just like any
other value can be assigned to a key.
wobble = {
'name': "Lorem Ipsum",
'age': 42,
'ratings': {
'badminton': 17.48,
'celery': None,
'fussball': 0.14,
},
'address': "175 West Arglbargle, Lower Snootbatten",
}
That has values that are themselves containers, so I suppose it counts
as a “complex” dictionary.
--
\ “I went to the museum where they had all the heads and arms |
`\ from the statues that are in all the other museums.” —Steven |
_o__) Wright |
Ben Finney
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor