Python - return multiple values using tuple (AWS lambda function)
<p>This is the current code that I have:</p>

<pre><code>def handler():
    ec2 = boto3.resource("ec2", region_name="ap-southeast-2")
    instances = ec2.instances.filter(Filters=[{'Name':'iam-instance-profile.arn', 'Values': ['arn:aws:iam::123456789012:instance-profile/TestRole']}])
    for instance in instances:
        return (instance.private_ip_address)
</code></pre>

<p>I'm trying to return all the private_ip_addresses. This code only returns me 1 ip address but I should be getting back 3 addresses. If i did a <code>print</code> instead, it returns the correct 3 values</p>

<p>I did some research and found using <strong>tuple</strong> is a good way but it hasn't been working for me thus far. Here is an example code I'm trying out with tuple (that should work with my code if it is correct)</p>

<pre><code>myList=[1,2,3,4,5,6]

def handler():
   tup=()
   for element in myList:
       tup+= (element,)
   return tup
</code></pre>

<p>This currently returns a null value. However, if i do <code> print tup </code>, it returns me with <code>(1, 2, 3, 4, 5, 6)</code></p>

<p>Can anyone let me know where I am going wrong with my use of tuple. OR if there is a better way to do this (corresponding with how lambda functions work)?</p>