can we append a list with another list in Python ?
Dave Angel
d at davea.name
Thu Oct 25 05:54:28 EDT 2012
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
More information about the Python-list
mailing list