Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Still working with dicts
#1
Given the current dict and data structure, doing a search for chicken pulls all recipes for chicken. If I wanted to refine that search for bourbon chicken, how would I go about digging deeper to get that key? Or should the data storage be different. I've been looking into json a little.
Thanks
Current scenario
recipes = {
    "chicken":[
        {"bourbon":[
            {"ingedients":"burbon, chicken, stove, pan","directions":"cook it and eat it"}
            ]},
        {"fried":[
            {"ingredients":"grease, chicken, seasonings","directions":"fry chicken and put seasons on it then eat"}
            ]}
        ],
    "beef":[
        {"hamburger":[
            {"ingredients":"1 pound of ground beef, forman grill, salt and pepper","directions":"you know the drill"}
            ]},
        {"spagetti":[
            {"ingredients":"noodles, sauce, hamburger","directions":"cook the stuff and pig out"}
            ]

            }
        ]
    }



print(type(recipes))

x = 'chicken'
if x in recipes:
    print(recipes[x])
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
Still working with dicts - by menator01 - Nov-06-2019, 09:49 PM
RE: Still working with dicts - by Larz60+ - Nov-06-2019, 11:07 PM
RE: Still working with dicts - by perfringo - Nov-07-2019, 07:15 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Star Recursively convert nested dicts to dict subclass Alfalfa 1 2,923 Jan-22-2021, 05:43 AM
Last Post: buran
  Split dict of lists into smaller dicts of lists. pcs3rd 3 2,440 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  convert List of Dicts into a 2 deep Nested Dict rethink 1 3,242 Aug-23-2019, 05:28 PM
Last Post: ichabod801
  Merge dicts without override chisox721 4 3,290 Jul-20-2019, 01:45 AM
Last Post: chisox721
  Python inventory system with dicts. 2skywalkers 7 6,030 Aug-23-2018, 05:06 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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