 <p>You can make a function like this:</p> <pre class="lang-python prettyprint-override"><code>def get_item(d, keys): current = d for k in keys: current = current[k] # You can add some error handling here return current </code></pre> <p>Example of usage: <a href="https://repl.it/E49o/1" rel="nofollow noreferrer">https://repl.it/E49o/1</a></p> <p>If you want to modify the value at the last index, you can do something like this. </p> <pre class="lang-python prettyprint-override"><code>def set_item(d, keys, new_value): current = d for k in keys[:-1]: # All the keys except the last one current = current[k] current[keys[-1]] = new_value </code></pre>