[Tutor] can i pass a list to a function and get one back ?

Bill Campbell bill at celestial.net
Sun Oct 22 03:26:14 CEST 2006


On Sat, Oct 21, 2006, shawn bright wrote:
>
>   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 ?

Ayup!

The best way to find answers to questions like this is to just do
it, and see what python does.

Bill
--
INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

``It will be of little avail to the people that the laws are made by men of
their own choice if the laws be so voluminous that they cannot be read, or
so incoherent that they cannot be understood.''
    -James Madison, Federalist Paper #62


More information about the Tutor mailing list