[Tutor] can i pass a list to a function and get one back ?
shawn bright
nephish at gmail.com
Sun Oct 22 08:14:58 CEST 2006
way cool, thanks. I am always looking for ways to clean things up
-sk
On 10/21/06, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> wrote:
>
>
>
> > great, thanks, i have idle right here, would have been just as easy.
> > sorry about that
>
> No problem; it's cool.
>
>
> >> > hey there, i was just wondering if i could get a list back from a
> >> > function.
> >> > something like
> >> > def return_a_list(some_var):
> >> > some_list = []
> >> > for i in range(5):
> >> > var = some_var + i
> >> > some_list.append(var)
> >> > return some_list
> >> > is this cool ?
>
> It's cool. *grin*
>
> One small comment: we often don't need to use temporary variables like
> 'var'.
>
> def return_a_list(some_var):
> some_list = []
> for i in range(5):
> some_list.append(some_var + i)
> return some_list
>
> Sometimes a temporary variable is useful, and sometimes not. Here, it
> seems like it's not too necessary.
>
>
> Good luck!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061022/c4db9313/attachment.htm
More information about the Tutor
mailing list