Conversion of List of Tuples
MRAB
python at mrabarnett.plus.com
Mon Dec 3 15:13:06 EST 2012
On 2012-12-03 20:04, John Gordon wrote:
> In <6049bc85-6f8e-429b-a855-ecef47a9d28e at googlegroups.com> subhabangalore at gmail.com writes:
>
>> Dear Group,
>
>> I have a tuple of list as,
>
>> tup_list=[(1,2), (3,4)]
>> Now if I want to covert as a simple list,
>
>> list=[1,2,3,4]
>
>> how may I do that?
>
> new_list = []
>
> for t in tup_list:
> for item in t:
> new_list.append(item)
>
Or you could use .extend:
new_list = []
for t in tup_list:
new_list.extend(t)
More information about the Python-list
mailing list