On 06/01/2017 07:17 AM, joannah nanjekye wrote:
Today I was writing an example snippet for the book and needed to write a
function that returns two values something
like this:
def return_multiplevalues(num1, num2):
return num1, num2
I noticed that this actually returns a tuple of the values which I did not
want in the first place.I wanted python to
return two values in their own types so I can work with them as they are but
here I was stuck with working around a tuple.
If you had a function that returned two values, how would you assign them?
Maybe something like:
var1, var2 = return_multiplevalues(num1, num2)
?
That is exactly how Python works.
I will appreciate discussing this. You may also bring to light any current way
of returning multiple values from a
function that I may not know of in python if there is.
While I am somewhat alarmed that you don't know this already after four years of Python programming, I greatly
appreciate you taking the time to find out. Thank you.
--
~Ethan~
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/