Add items in nested dictionaries based on ID number in python
<p>I have dictionaries nested in a list. The dictionaries are set up as follows:</p>

<p><code>{'ID': 123, 'Balance': 45, 'Comments': None}</code></p>

<p>I have multiple of these dictionaries in a list, so the list looks like this:</p>

<pre><code>[{'ID': 123, 'Balance': 45, 'Comments': None}, {'ID': 456, 'Balance': 78, 'Comments': None}]
</code></pre>

<p>What I'm trying to do, is check to see if there is already a dictionary with the ID from the input in the list, and if there is, add the Balance from the input. 
Is there any readable pythonic way to do this?</p>

<p>Iterate over the list, check that whether there is match with the <code>ID</code>, if yes, add the value to the existing value of <code>BALANCE</code> of that dict. Below is the sample code:</p>

<pre><code>&gt;&gt;&gt; my_dict_list = [{'ID': 123, 'Balance': 45, 'Comments': None}, {'ID': 456, 'Balance': 78, 'Comments': None}]
&gt;&gt;&gt; 
&gt;&gt;&gt; new_id = int(raw_input())
123
&gt;&gt;&gt; for dict_obj in my_dict_list:
...     if new_id == dict_obj['ID']:
...         dict_obj['Balance'] += float(raw_input())
... 
34
&gt;&gt;&gt; my_dict_list
[{'Balance': 79.0, 'ID': 123, 'Comments': None}, {'Balance': 78, 'ID': 456, 'Comments': None}]
# Value updated for "ID" 123
</code></pre>

python list dictionary nested