[Tutor] Standard way to append to a list?
Blake.Garretson@dana.com
Blake.Garretson@dana.com
Tue Apr 15 08:30:02 2003
Brian Christopher Robinson <brian@dungeoncrawl.org> writes:
>Say I have:
>list = [1, 2, 3]
>What is the standard way to add 4 to the end of the list? I know:
>list = list + [4]
>would work. What else is there?
Try this:
List = [1, 2, 3]
List.append(4)
Also handy for adding more than one item:
List.extend([4,5,6])
By the way, I know this is just an example, but I would avoid using the
word "list" since it is a built-in.
-Blake Garretson