title: How to best save a value from a nested loop in a variable for further calculations
body: <p>I have a nested loop function and want to return the last value to use it for further calculations. I dont want to use a list.append() method since each run of the loop only yields one value.
  The code looks like this:</p>
  <pre><code>def lambda_handler(event, context):
   for record in event['Records']:
        if record['eventName'] == &quot;INSERT&quot; and &quot;WW&quot; in record[&quot;dynamodb&quot;][&quot;NewImage&quot;]:
             details = record[&quot;dynamodb&quot;][&quot;NewImage&quot;]
             for k,v in details.items():
                  if k == 'WW':
                       for key in v:
                            print(v[key])
  </code></pre>
  <p>Now I want to store the value for v[key] in a variable to use for further calculations. How can this be done best?</p>
  <p>Thank you in advance</p>
  <p>A</p>