De-tupleizing a list

CM cmpython at gmail.com
Tue Apr 26 05:42:51 CEST 2011


On Apr 25, 11:28 pm, Gnarlodious <gnarlodi... at gmail.com> wrote:
> I have an SQLite query that returns a list of tuples:
>
> [('0A',), ('1B',), ('2C',), ('3D',),...
>
> What is the most Pythonic way to loop through the list returning a
> list like this?:
>
> ['0A', '1B', '2C', '3D',...
>
> -- Gnarlie

For just this case, if returned_list is your list above, how about?:

flat_list = [item[0] for item in returned_list]




More information about the Python-list mailing list