0

I am learning python and i would like to know how can i loop nested dictionary with for loop and also with dictionary comprehension ?

Here is the code:

users = {"user_1": {"name": "John"}, "user_2": {"name": "Michael"}, "user_3": {"name": "Richard"}}
paka_29
  • 9
  • 1
  • You should probably be more precise about the desired output. Do you want to see the key of the inner dicts? the values? – T.Nel Jul 24 '18 at 08:51
  • Yes of course :) i would like to see all the keys and values in there. – paka_29 Jul 24 '18 at 08:54
  • I checked the link and now its working with for loop. Thank you :) how about dictionary comprehension ? – paka_29 Jul 24 '18 at 09:03
  • I had a second link for that but it was removed with the dupe. Here it is : https://stackoverflow.com/questions/17915117/nested-dictionary-comprehension-python . I don't want to look rude, but it is the first result I found typing "nested dict comprehension python". Try to do some research before posting here, and welcome to SO – T.Nel Jul 24 '18 at 09:10
  • Oh sorry i didnt noticed that. I am new here so.. i will learn :D – paka_29 Jul 24 '18 at 09:13

0 Answers0