How to extract 'hello' from the following nested dictionary using indexing?

John

How can I extract hello from the code using indexing?

I_say = {'stairs_1':[1, 'two', {'stairs_2':['Close to the door', {'in the door':['one', 2, ['hello']]}]}]}
EgorLu

I completely understand why this question was downvoted. It's just basic knowledge that a Python tutorial would help you with.

Nevertheless, it would help you immensely if you'd reformat your code and make it more readable.

{
  "stairs_1":[
    1,
    "two",
    {
      "stairs_2":[
        "Close to the door",
        {
          "in the door":[
            "one",
            2,
            [
              "hello"
            ]
          ]
        }
      ]
    }
  ]
}

After looking at this code, you can see that the first level is a dictionary with a key stairs_1, its value is a list of three values.

The third value is a dictionary that contains just one element. Again, stairs_2 is the key and the value is a list, this time of two elements.

The second element is a dictionary that contains one element, its key is in the door and the value is a list.

The list contains three elements, while the third one is a list with a single element - your "hello" string.

So the answer is I_say['stairs_1'][2]['stairs_2'][1]['in the door'][2][0]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do i extract from a nested dictionary?

How to extract the value from a nested dictionary within a nested list in python

How do I extract a nested alphanumeric value from a dictionary using Python

How to extract text from a string with Python using indexing and slicing

How to extract values from nested dictionary variable in robot framework?

how to extract data from a nested dictionary of a key in python

How to extract selected key and value from nested dictionary object in a list?

Ansible : How to extract a nested dictionary value from a JSON response in YAML

How to extract lists and modify them from different levels of nested dictionary

How to extract values from each entry in nested dictionary?

How to extract desired field from nested dictionary in python

How do I extract strings from a nested dictionary in Python

Indexing a value in a nested dictionary

Indexing a namedtuple nested in a dictionary

indexing nested dictionary elements

How to build the following dictionary, from a list using regex?

How to extract only the URL from the following strings using regular expressions?

Python extract max value from nested dictionary

Python - Extract data from nested dictionary into Excel

extract dictionary elements from nested list in python

Using regex to extract data from the following string

How to extract data from a dictionary?

How to extract a list from a dictionary

How to extract the dictionary from list of dictionary with condition

Indexing a dictionary from file

How to create nested dictionary from XML using python?

How to Extract a Specific Value from Nested JSON Data using LINQ?

How to extract data from nested Json in Jmeter using Json Extractor

How to extract keys from multiple, nested arrays using jq