python add value in dictionary in lambda expression
<p>Is it possible to add values in dictionary in lambda expression?</p>

<p>That is to implement a lambda which has the similar function as below methods.</p>

<pre><code>def add_value(dict_x):
    dict_x['a+b'] = dict_x['a'] + dict_x['b']
    return dict_x
</code></pre>

<p>Technically, you may use side effect to update it, and exploit that <code>None</code> returned from <code>.update</code> is falsy to return dict via based on boolean operations:</p>

<pre><code>add_value = lambda d: d.update({'a+b': d['a'] + d['b']}) or d
</code></pre>

<p>I just don't see any reason for doing it in real code though, both with lambda or with function written by you in question.</p>

python