Noah, Calvin

Thanks so much!

Regards,
Emeka

On Wed, Dec 21, 2011 at 6:57 AM, Noah Hall <enali...@gmail.com> wrote:

> On Wed, Dec 21, 2011 at 4:39 AM, Emeka <emekami...@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?
>
> It's because add_to_list returns the value returned from plist.append
> stored in u.
> append changes a list in place and returns nothing. Functions that
> return nothing return None. This is why it'll be None - u is None
> because append returns None.
>
>
> > add_to_list([])
> > This one returns nothing, why?
>
> It's because the object [] here has no name, so that you have no way
> to refer to it after the function changes it, since it changes it in
> place. It gets eaten by Python, never to be seen again.
>



-- 
*Satajanus  Nig. Ltd


*
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to