Possible Duplicate:
How to flatten a nested dictionary in python 2.7x
If I have a dictionary:
dictionaryname= { 'key1' : 'value1',
'key2' : 'value2',
'key3' : { 'key3a': 'value3a' },
'key4' : { 'key4a': { 'key4aa': 'value4aa',
'key4ab': 'value4ab',
'key4ac': 'value4ac'},
'key4b': 'value4b'}
}
How do I make it so that the result would be as follows:
key1
value1
key2
value2
key3
key3a
value3a
...
I just have to print whole dictionary, not necessarily in the right order.
If I use:
def print_all(dictionaryname):
for i in dictionaryname:
print i
I only get:
key1
key2
key3
...
What should I do?
1 Answer