[Tutor] can i pass a list to a function and get one back ?
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
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
> 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...
More information about the Tutor