I have multiple sets of pairing lists stored in the dictionaries "dates" and "prices". The lists are of unkown sizes, but I would like to print them side by side as in:
date_value1 price_value1 date_value2 price_value 2
At this moment, however I can only get it to print one after the other, as in:
for i in range(len(cities)):
for j,k in zip(dates[i],prices[i]):
print str(i) + " ; " + j.text +" ; "+ k.text
I have tried to get it to do what I want by doing:
a = {}
for i in range(len(cities)):
for j,k in zip(dates[i],prices[i]):
print str(i) + " ; " + j.text +" ; "+ k.text
try: a[i] = a[i-1] + " ; " + j.text +" ; "+ k.text
except: a[i] = " ; " + j.text +" ; "+ k.text
for i in a[len(cities)-1]:
print a
But it does something else entirely different which I really couldnt figure out.
Can you help? Thanks.
This is how I fixed my code. Thank you F.J
a = 100000
for i in xrange(len(citynames)):
if len(precos[i]) < a: a = len(precos[i])
print citynames[i], " ; "," ; ",
print
for j in xrange(a):
for i in xrange(len(citynames)):
print datas[i][j].text, " ; " ,precos[i][j].text, " ; ",
print