append on lists

Arnaud Delobelle arnodel at googlemail.com
Mon Sep 15 16:22:06 EDT 2008


On Sep 15, 9:24 pm, Armin <a... at nospam.org> wrote:
> Hi,
>
> just a dumb question.
>
> Let a = [1,2,3,4,5]
>
> Why is the value of a.append(7) equal None and not [1,2,3,4,5,6,7] ??
>
> --Armin

Because list.append is a method that mutates its object, and such
method usually return None.  What you should check is the value of 'a'
after 'a.append(7)'.

--
Arnaud



More information about the Python-list mailing list