Damn error!

Guilherme Polo ggpolo at gmail.com
Mon Dec 24 07:46:22 EST 2007


Em 24/12/07, Vaurdan<armyportalrs at gmail.com> escreveu:
> Hello,
> I've this code:
> def print_tabela(tabela):
>         print "Tabela 1 | Tabela 2"
>         for linha in tabela:
>                         tmp = linha.split(":")
>                         print tmp[0] + " | " + tmp[1],
>
> But give me this error:
> Tabela 1 | Tabela 2
> Traceback (most recent call last):
>   File "./teste.py", line 126, in <module>
>     print_tabela(conteudo)
>   File "./teste.py", line 58, in print_tabela
>     print tmp[0] + " | " + tmp[1],
> IndexError: list index out of range

'linha' doesn't have a ":" on it, so when you split you get something
like [yourlinhacontents] therefore tmp[1] is out of range.

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


-- 
-- Guilherme H. Polo Goncalves



More information about the Python-list mailing list