[Tutor] can i pass a list to a function and get one back ?
kent37 at tds.net
Sun Oct 22 13:33:54 CEST 2006
Danny Yoo wrote:
> 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.
some_list is not too necessary either; this is a good place for a list
return [ some_var + i for i in range(5) ]
or for that matter
More information about the Tutor