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


Groups > comp.lang.python > #32105

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

Date 2012-10-25 05:54 -0400
From Dave Angel <d@davea.name>
Subject Re: can we append a list with another list in Python ?
References (6 earlier) <CAFqGZREsGdQC-b2mGUqRESjfA38L2LJR1b_j62AHm66xwkxpvQ@mail.gmail.com> <50890388.8030809@davea.name> <CAFqGZRG5QytqNxAfh60RNGv1V-DF8938rbDVy8Tf2S5+g4+oGA@mail.gmail.com> <508906DF.1090804@davea.name> <CAFqGZRGfzxzQR0-WrCTaCquxh7kdhu4rOgEm5d17L-tQTohjCA@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2826.1351158891.27098.python-list@python.org> (permalink)

Show all headers | View raw


On 10/25/2012 05:44 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
> 
> 
> Ok but it should be clist + = [alist, blist ] ????
> 
>>
>>
>> --
>>
>> DaveA
>>
> 

No, try it and see.  a,b is a tuple, and [a,b] is a list.  But if you're
doing the +=, and the LHS is a list, then it'll work with any iterable.

BTW, the extra space in your new line will also be a problem.  The plus
and the equals must be adjacent, without an intervening space.


-- 

DaveA

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


Thread

Re: can we append a list with another list in Python ? Dave Angel <d@davea.name> - 2012-10-25 05:54 -0400

csiph-web