How can i return more than one value from a function to more than one variable

Joel Goldstick joel.goldstick at gmail.com
Sun Dec 22 19:05:37 EST 2013


return a tuple:

return a, b, c

or whatever


On Sun, Dec 22, 2013 at 6:41 PM, Bob Rashkin <rrashkin at gmail.com> wrote:

> On Sunday, December 22, 2013 4:54:46 PM UTC-6, dec... at msn.com wrote:
> > basically what I wanna do is this :
> >
> >
> >
> > x = 4
> >
> > y = 7
> >
> > def switch (z,w):
> >
> > ***this will switch z to w and vice verca***
> >
> >      c= z
> >
> >      z=w
> >
> >      w=c
> >
> >      print 'Now x =', w, 'and y = ' , z
> >
> >      return w
> >
> > x = switch(x,y)
> >
> >
> >
> >  How am I supposed to do so I can  return also a value to the variable y
> WITHOUT printing 'Now x =', w, 'and y = ' , z   a second time ?
> >
> >
> >
> > thanks in advance
>
> Not sure I understand the problem but I think the answer is to put
> multiple values in a list and return the list.
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131222/bb62a028/attachment.html>


More information about the Python-list mailing list