Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31922

Re: can we append a list with another list in Python ?

References <CAFqGZRHGgN_tEinBku9cj78D_VawZgP3F8k5+FKen0mW3AeVbg@mail.gmail.com>
From Zero Piraeus <schesis@gmail.com>
Date 2012-10-23 04:56 -0400
Subject Re: can we append a list with another list in Python ?
Newsgroups comp.lang.python
Message-ID <mailman.2654.1350982586.27098.python-list@python.org> (permalink)

Show all headers | View raw


:

On 23 October 2012 03:36, inshu chauhan <insideshoes@gmail.com> wrote:
> can we append a list with another list in Python ? using the normal routine
> syntax but with a for loop ??

The standard way to append the contents of one list to another is list.extend:

>>> a = [1, 2, 3]
>>> b = [4, 5, 6]
>>> a.extend(b)
>>> a
[1, 2, 3, 4, 5, 6]

... but I'm not sure what you mean by "... with a for loop"?

 -[]z.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: can we append a list with another list in Python ? Zero Piraeus <schesis@gmail.com> - 2012-10-23 04:56 -0400

csiph-web