[Python] Python Add data from array to prettytable via column

Discussão em 'Python' iniciado por Stack, Janeiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I created an array full of number. I want to add data from the array to the prettytable basically using add_columns

    number=[1,2,3,4,5,6,7,8,9,.....,100]


    I want the output of the pretty table to be like this below

    +-----------+------+------------+-----------------+
    | Number |1 | 2 | 3 | 4 | ..... |
    +-----------+------+------------+-----------------+


    My code is shown below.

    from prettytable import PrettyTable

    x = PrettyTable()
    x.add_column(["number", print(number)])
    print(x)


    When I run the python script, it generated an error


    TypeError: add_column() missing 1 required positional argument: 'column'
    ​

    How to achieve this?

    Continue reading...

Compartilhe esta Página