> def print_tabela(tabela):
 >      print "Tabela 1 | Tabela 2"
 >      for linha in tabela:
 >                      tmp = linha.split(":")

in here, insert this:
                         print len(tmp),

 >                      print tmp[0] + " | " + tmp[1],

I also think you may not want the trailing comma on the print line 
above.  Notice that, right before this,

 >     print tmp[0] + " | " + tmp[1],
 > IndexError: list index out of range

it has printed something less than 2.  Looks like your data isn't what 
you  think it is, as it doesn't appear to have a colon in one of the 
lines.  You might even try

   for i, linha in enumerate(tabela):
     tmp = linha.split(":")
     if len(tmp) != 2:
       print "On line %i, got [%s]" % (i+1, linha)
     print tmp[0] + " | " + tmp[1]

Or, for a more compact way of writing the original code with a bit more 
gracious handling:

   for linha in tablea:
     print " | "".join(linha.split(":")[:2])

-tkc





-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to