Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62562

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

Newsgroups comp.lang.python
Date 2013-12-22 15:41 -0800
References <40ddd2cf-483f-423b-9a4d-93f6a5e77df2@googlegroups.com>
Message-ID <8e01f218-ec00-4d01-ab82-53e1ea7670e2@googlegroups.com> (permalink)
Subject Re: How can i return more than one value from a function to more than one variable
From Bob Rashkin <rrashkin@gmail.com>

Show all headers | View raw


On Sunday, December 22, 2013 4:54:46 PM UTC-6, dec...@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.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: How can i return more than one value from a function to more than one variable Bob Rashkin <rrashkin@gmail.com> - 2013-12-22 15:41 -0800
  Re: How can i return more than one value from a function to more than one variable Joel Goldstick <joel.goldstick@gmail.com> - 2013-12-22 19:05 -0500
  Re: How can i return more than one value from a function to more than one variable Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-23 00:37 +0000
    Re: How can i return more than one value from a function to more than one variable Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-22 22:17 -0500
  Re: How can i return more than one value from a function to more than
 one variable Dave Angel <davea@davea.name> - 2013-12-22 19:57 -0500
  Re: How can i return more than one value from a function to more than one variable Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-23 11:45 +1100

csiph-web