Tuples --> How to use them ?

Thomas Guettler zopestoller at thomas-guettler.de
Thu Jul 4 06:38:15 EDT 2002


Marcus Vinicius Laranjeira wrote:

> All,
> 
> Supose I have an arbitrary tuple of values that came from a sql query. I 
> need to run this algorithm:
> 
> t1 <-- new tuple
> t1 <-- results from an arbitrary query
> l <-- new list
> for each value in the tuple do:
>     a <-- new tuple
>     add this value to the tuple a
>     add the tuple a to a the list l
> 
> i.e. I need to create a list of tuples and these tuples will have one, 
> and only one, number that came from the original tuple.
> 
> Does anyone know how do I do that !?


#creating new tuple is not necessary
t1=query()
l=[]
for value in t1:
	l.append([value])

thomas





More information about the Python-list mailing list