Please explain this for me

Calvin Spealman ironfroggy at gmail.com
Tue Dec 20 23:54:36 EST 2011


On Dec 20, 2011 11:41 PM, "Emeka" <emekamicro at gmail.com> wrote:
>
>
> Hello All,
>
> v = []
>
> def add_to_list(plist):
>     u = plist.append(90)
>     return u
>
> add_to_list(v)  # This function call returns nothing
> Could someone explain why this function call will return nothing?
>
> v = [90] # Object values are passed by reference
> This one is clear to me
>
> add_to_list([])
> This one returns nothing, why?

Because list.append() returns nothing, it only modifies the list in place.

>
> Regards,
> Emeka
> --
> Satajanus  Nig. Ltd
>
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111220/f2cfa875/attachment.html>


More information about the Python-list mailing list