Python Forum
convert List of Dicts into a 2 deep Nested Dict
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convert List of Dicts into a 2 deep Nested Dict
#2
It should be pretty easy. Start with an empty main dictionary. Loop through the list. If the user name is not in the main dictionary, add it as a key with an empty sub-dictionary as the value. Then add the game to the sub-dictionary.

Try that. If it doesn't work, show us the code you wrote and what the problem is, and we can help you fix it.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: convert List of Dicts into a 2 deep Nested Dict - by ichabod801 - Aug-23-2019, 05:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List all possibilities of a nested-list by flattened lists sparkt 1 926 Feb-23-2023, 02:21 PM
Last Post: sparkt
  convert string to float in list jacklee26 6 1,931 Feb-13-2023, 01:14 AM
Last Post: jacklee26
  convert a list to links Pir8Radio 3 1,107 Nov-28-2022, 01:52 PM
Last Post: Pir8Radio
  convert this List Comprehensions to loop jacklee26 8 1,533 Oct-21-2022, 04:25 PM
Last Post: deanhystad
  Membership test for an element in a list that is a dict value for a particular key? Mark17 2 1,228 Jul-01-2022, 10:52 PM
Last Post: Pedroski55
  Are list/dict comprehensions interpreted really sequentially? anata2047 3 1,467 May-31-2022, 08:43 PM
Last Post: Gribouillis
  Convert nested sample json api data into csv in python shantanu97 3 2,856 May-21-2022, 01:30 PM
Last Post: deanhystad
  Convert list to interger Clives 5 1,639 May-09-2022, 12:53 PM
Last Post: deanhystad
  Convert python dataframe to nested json kat417 1 6,354 Mar-18-2022, 09:14 PM
Last Post: kat417
  Updating nested dict list keys tbaror 2 1,291 Feb-09-2022, 09:37 AM
Last Post: tbaror

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020