I have a nested data structure python dictionary. I want to read its keys and values withoutusing a module collection. The data structure is similar to the one below.
d = {'dict1': {'foo': 1, 'bar': 2}, 'dict2': {'baz': 3, 'quux': 4}}
I tried to read the keys in the dictionary using the following method, but getting an error.
the code
for key, value in d:
print(Key)
Error
ValueError: too many values to unpack (expected 2)
So can someone explain the cause of the error and how to iterate through the dictionary.
source
share