In python list I have two items per element, 1st a str, second a float
L= [('A', Decimal('52.00')), ('B', Decimal('87.80')), ('G', Decimal('32.50'))]
I want use a for loop both item in the element
NewL= []
for row in L:
### do something with str
InSql= "SELECT " % str
f= csr.execute(InSql)
ns = list(f)
###do something with float
InSql= "SELECT " % float
f= csr.execute(InSql)
nf = list(f)
NewL.append(str, float,ns, nf)
Change your for loop to something like this:
for str_data, float_data in L:
# str_data is the string, float_data is the Decimal object
Two ways:
First you could access the members of row:
#For string:
row[0]
#For the number:
row[1]
Or you specify your loop this way:
for (my_string, my_number) in l:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With