Can Python function return multiple data?

Joel Goldstick joel.goldstick at gmail.com
Tue Jun 2 17:35:51 EDT 2015


On Tue, Jun 2, 2015 at 5:27 PM, fl <rxjwg98 at gmail.com> wrote:
> Hi,
>
> I just see the tutorial says Python can return value in function, it does
> not say multiple data results return situation. In C, it is possible.
> How about Python on a multiple data return requirement?
>
>
> Thanks,
> --
> https://mail.python.org/mailman/listinfo/python-list

Yes!

def my_function(n):
    return n, n*2

a_number, its_double = my_function(3)

a_number will be 3, its_double will be 6

-- 
Joel Goldstick
http://joelgoldstick.com



More information about the Python-list mailing list