Python: Convert list to dict keys for multidimensional dict with exception handling
<p>I have a collection of multidimensional dictionaries that looks as follows</p>

<pre><code>dict1 = {'key21':{'key31': {'key41':val41}, 'key32':{'key42':val42}}}
</code></pre>

<p>Apriori, I dont know the dimensions of the dictionary. I have a huge collection of possible keys and each dictionary might or might not contain the keys. Even if present, the keys may not have to be in the same order.</p>

<p>If I create a list of possible key values from the collection, say</p>

<pre><code>list1 = ['key21', 'key32', 'key42']
</code></pre>

<p>How can I pass the list as key so that I can get the value of <code>dict1['key21']['key32']['key42']</code> with exception handling similar to <a href="http://www.tutorialspoint.com/python/dictionary_get.htm" rel="nofollow">get</a> command</p>