kragniz / kragniz/prettytable

Creating a PrettyTable inside a for.

Open
#66 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
Python
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

```
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

Contributor guide

No contributing guide indexed for this repository

Research direction

No repository file or test is named. Start by reviewing the reported loop and the PrettyTable.add_row call, then determine what usage guidance would address the TypeError; done means providing a clear explanation of how to construct and populate the table.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.