As always in python, there are of course several ways to do it, but there is one obvious way to do it.

tmpdict["ONE"]["TWO"]["THREE"] is the obvious way to do it.

When that does not fit well with your algorithm, that may be a hint that your structure is not the best for the problem.

If you just want to just save you repetative typing, you can of course alias a subset of the dict:

>>> two_dict = tmpdict['ONE']['TWO'] # now you can just write two_dict for tmpdict['ONE']['TWO']
>>> two_dict["spam"] = 23
>>> tmpdict
{'ONE': {'TWO': {'THREE': 10, 'spam': 23}}}
Answer from ch3ka on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › accessing-value-inside-python-nested-dictionaries
Python - Accessing Nested Dictionaries - GeeksforGeeks
July 23, 2025 - Easiest method to access Nested dictionary is by using keys. If you know the structure of nested dictionary, this method is useful.
Discussions

How to access nested dictionary and set value in it.
There aren't pointers in Python in the sense that you could return a value from get_nested_value and assigning to that value directly changes dict_var. However, dict is a mutable reference type, so changes to dict_obj or its sub-dictionaries from within a function that you pass it to would modify the original. So this would work: def set_nested_value(dict_obj, value, *args): *args, final = args temp = dict_obj for key in args: temp = temp[key] temp[final] = value set_nested_value(dict_var, "test", 'a', 'b', 'c') You could also return an object that has a reference to the final nested dictionary and a method or property for setting a value on a particular key, which can emulate a pointer: class DictProxy: def __init__(self, dictionary, key): self.dictionary = dictionary self.key = key @property def value(self): return self.dictionary[self.key] @value.setter def value(self, new_value): self.dictionary[self.key] = new_value def get_nested_value(dict_obj, *args): *args, final = args temp = dict_obj for key in args: temp = temp[key] return DictProxy(temp, final) something = get_nested_value(dict_var, 'a', 'b', 'c') something.value = "test" # This modifies 'dict_var' More on reddit.com
🌐 r/learnpython
2
2
November 12, 2021
Using get() with nested dictionary.
When get misses, the default return is None, which can't itself be "get"ed. You could have get give a different miss, like a dictionary, which could then give you further misses. I might do that for a single layer, but with a bunch, I would probably do something like create a function to do the search for me, probably recursively. edit: some great ideas here: https://stackoverflow.com/questions/25833613/safe-method-to-get-value-of-nested-dictionary Having never had the chance to use reduce, I would 100% use one of those solutions. More on reddit.com
🌐 r/learnpython
9
5
April 10, 2024
How to get value inside nested dictionary
When you iterate a dictionary directly, you're given the keys of the dictionary, meaning x is each key ('0', '1', ...). You want to iterate the values of the dictionary instead: for inner_dict in data.values(): print(inner_dict["account_id"]) More on reddit.com
🌐 r/learnpython
3
0
September 29, 2021
How to walk through a nested dictionary with it's keys in a list?
What I would do is make a copy of the dict to a temporary dict and then index it with a for loop: T = D for i in L: T = T[i] Now T will be equal to D['product']['item']['serial_key'] Check out working example: http://codepad.org/64NhJMBS More on reddit.com
🌐 r/learnpython
24
129
March 9, 2021
🌐
W3Schools
w3schools.com › python › python_dictionaries_nested.asp
Python - Nested Dictionaries
To access items from a nested dictionary, you use the name of the dictionaries, starting with the outer dictionary: ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ...
🌐
Learn By Example
learnbyexample.org › python-nested-dictionary
Python Nested Dictionary - Learn By Example
June 20, 2024 - This generates a nested dictionary ... You can access elements within a nested dictionary by specifying multiple keys in a chain, using square brackets []. Each key represents a level of nesting....
🌐
Programiz
programiz.com › python-programming › nested-dictionary
Python Nested Dictionary (With Examples)
To access element of a nested dictionary, we use indexing [] syntax in Python.
🌐
Codingem
codingem.com › home › python how to access nested dictionary (with 5+ examples)
Python How to Access Nested Dictionary (with 5+ Examples)
December 4, 2022 - To access a nested dictionary values, apply the access operator on the dictionary twice. For example dict['key1']['key2'].
🌐
Medium
medium.com › @ryan_forrester_ › python-nested-dictionaries-complete-guide-8a61b88a2e02
Python Nested Dictionaries: Complete Guide | by ryan | Medium
October 24, 2024 - A nested dictionary is simply a dictionary that contains other dictionaries as values. Here’s a basic example: employee = { 'name': 'Sarah Chen', 'position': { 'title': 'Senior Developer', 'department': 'Engineering', 'details': { 'level': ...
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-nested-dictionary
Python Nested Dictionary - GeeksforGeeks
July 12, 2025 - This program shows how to access specific values from a nested dictionary by using outer and inner keys.
🌐
Career Karma
careerkarma.com › blog › python › python nested dictionary: a how-to guide
Python Nested Dictionary: A How-To Guide | Career Karma
December 1, 2023 - If we did not use a nested dictionary, ... about ice cream flavors. To access an item in a nested dictionary, we can use the indexing syntax....
🌐
Towards Data Science
towardsdatascience.com › home › latest › nested dictionary python – a complete guide to python nested dictionaries
Nested Dictionary Python - A Complete Guide to Python Nested Dictionaries | Towards Data Science
January 22, 2025 - There’s a lot that goes into working with nested dictionaries in Python. You can access individual values, change them, add new rows, delete old ones, merge multiple dictionaries, iterate over them, and even convert the entire thing to a Pandas DataFrame or JSON file.
🌐
CodeSpeedy
codespeedy.com › home › how to access elements of a nested dictionary in python
How to access elements of a nested dictionary in Python - CodeSpeedy
November 26, 2021 - Until now we learned to create how to create a Nested Dictionary now let’s see how to access Nested Dictionary’s elements. people = {1: {'name' : 'CodeSpeedy', 'age' : '34'}, 2: {'name' : 'Yash', 'age' : '23'}} print(people[1]['name']) print(people[2]['age']) ... Also read: How to call a Nested function: Python nested function Call!
🌐
Tutorialspoint
tutorialspoint.com › python › python_nested_dictionaries.htm
Python - Nested Dictionaries
We can achieve this through direct indexing with square brackets or by using the get() method · In this approach, we access values in a nested dictionary by specifying each key in a sequence of square brackets.
🌐
Python Examples
pythonexamples.org › python-nested-dictionary
Python Nested Dictionary - Dictionary inside Dictionary
In the previous example above, we have created a nested dictionary of depth two. In the following program, we shall access a value from this dictionary with key moo. myDict = { 'foo': { 'a':12, 'b':14 }, 'bar': { 'c':12, 'b':14 }, 'moo': { 'a':12, 'd':14 }, } print(myDict['moo']['a']) print(myDict['moo']['d']) ... In this tutorial of Python Examples, we learned what a nested dictionary is, how to create a nested dictionary and how to access values of a nested dictionary at different depths.
🌐
Scaler
scaler.com › home › topics › what is nested dictionary in python?
What is Nested Dictionary in Python? | Scaler Topics
May 4, 2023 - We can create a nested dictionary in python using the dict() Constructor · We can access a nested dictionary in python using either the index or the keys of the dictionary.
🌐
GeeksforGeeks
geeksforgeeks.org › python-safe-access-nested-dictionary-keys
Python | Safe access nested dictionary keys - GeeksforGeeks
May 15, 2023 - Method #1 : Using nested get() This method is used to solve this particular problem, we just take advantage of the functionality of get() to check and assign in absence of value to achieve this particular task.
🌐
datagy
datagy.io › home › python posts › python dictionaries › python nested dictionary: complete guide
Python Nested Dictionary: Complete Guide • datagy
December 15, 2022 - In this case, we were able to access the key’s value through direct assignment. If that key didn’t previously exist, then the key (and the value) would have been created. Python dictionaries use the del keyword to delete a key:value pair in a dictionary. In order to do this in a nested dictionary, we simply need to traverse further into the dictionary.
🌐
Finxter
blog.finxter.com › home › learn python blog › python get values from a nested dictionary
Python Get Values from a Nested Dictionary - Be on the Right Side of Change
September 4, 2022 - Line [1] calls the for loop, references id from the top-level dictionary, info from the nested dictionary, and calls employees.items() to retrieve the appropriate data.
🌐
Academind
academind.com › tutorials › python-accessing-nested-dictionaries
Accessing Nested Dictionaries
November 14, 2018 - Working with .json data is a very common task, no matter if you’re coming from the data science or the web development world. Let’s see how we can access, modify and save .json data in Python.
🌐
TutorialsPoint
tutorialspoint.com › How-to-access-nested-Python-dictionary-items-via-a-list-of-keys
How to access nested Python dictionary items via a list of keys?
March 5, 2020 - The easiest and most readable way to access nested properties in a Python dict is to use for loop and loop over each item while getting the next value, until the end. example
🌐
Reddit
reddit.com › r/learnpython › how to access nested dictionary and set value in it.
r/learnpython on Reddit: How to access nested dictionary and set value in it.
November 12, 2021 -

I have a class which have dict_var. From another file I want to access this dict_var by using class methods. To retrieve value I have a class methods which takes *args and return correct value (look at the code). My question is how to set new value? is there any pointer like things in python? or set value directly to `id()` of a object. Thanks in advance.

dict_var={
    "a":{
        "b":{
            "c":0
        },
        "d":{
            "e":{
                "f":0
            }
        }
    },
    "x":12
}

#i can retrieve the value using for loop.
def get_nested_value(dict_obj, *args):
    """Return value from inside a nested dictionary"""
    temp = dict_obj
    for key in args:
        temp = temp[key]
    return temp

print(get_nested_value(dict_var,'a','b','c')) #0