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


Groups > comp.lang.python > #32102

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

References (5 earlier) <CAFqGZRE9P7RxjfR1jj316ozN39rXyWjQzz1yGThYB-vP=mKs1Q@mail.gmail.com> <CAFqGZREsGdQC-b2mGUqRESjfA38L2LJR1b_j62AHm66xwkxpvQ@mail.gmail.com> <50890388.8030809@davea.name> <CAFqGZRG5QytqNxAfh60RNGv1V-DF8938rbDVy8Tf2S5+g4+oGA@mail.gmail.com> <508906DF.1090804@davea.name>
Date 2012-10-25 05:47 -0400
Subject Re: can we append a list with another list in Python ?
From David Hutto <dwightdhutto@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2823.1351158473.27098.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Oct 25, 2012 at 5:31 AM, Dave Angel <d@davea.name> wrote:
> On 10/25/2012 05:21 AM, inshu chauhan wrote:
>>>
>>> or if the clist initial contents were relevant, perhaps you mean
>>>
>>>> clist += alist, blist
>>>
>>
>> But not this because it will simply concatenate the  list like
>> [1,2,3,4,5,6] .. I dont want this actaully...
>>
>>>
>
> No, it won't.  Try it to see.
>

Is this what you mean:

>>> list_1 = [i for i in range(0,5)]
>>> list_2 = [i for i in range(5,11)]
>>> for i in list_2:
...     list_1.append(i)
...
>>> list_1
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


or would another example help you out more?

-- 
Best Regards,
David Hutto
CEO: http://www.hitwebdevelopment.com

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


Thread

Re: can we append a list with another list in Python ? David Hutto <dwightdhutto@gmail.com> - 2012-10-25 05:47 -0400

csiph-web