Skip to content

Creating a PrettyTable inside a for. #66

@GoogleCodeExporter

Description

@GoogleCodeExporter
Hello!

I'm trying to create a list inside a for and I'm doing this way:
________________________________________________________
for i in PSOE_data:
   if i[0] + i[1] + i[2] != 0:
        newList.append(i)

PSOE_list = PrettyTable(["Digital Chanel", "State", "Hour", "Minute", "Second"])
PSOE_list.align["Digital Chanel"] = "c" # Alinhamento pela esquerda
PSOE_list.padding_width = 1 # Espaçamento entre colunas (default)
PSOE_list.add_row([newList[i][3], newList[i][4], newList[i][0], newList[i][1], 
newList[i][2]])
print PSOE_list
________________________________________________________

But there is traceback that says:

    PSOE_list.add_row([newList[i][3], newList[i][4], newList[i][0], newList[i][1], newList[i][2]])
TypeError: list indices must be integers, not list


How can I deal with that?

Thank you!

Original issue reported on code.google.com by dionatan...@gmail.com on 19 Feb 2015 at 1:43

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions