Trouble using add_row with prettytable
Question: I am trying to format an array using the `prettytable` library. Here is my
code:

    
    
    from prettytable import PrettyTable
    arrayHR = [1,2,3,4,5,6,7,8,9,10]
    print ("arrayHR:", arrayHR)
    x = PrettyTable(["Heart Rate"])
    for row in arrayHR:
        x.add_row(row)
    

This results in the following error:

    
    
    arrayHR: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        Traceback (most recent call last):
          File "C:\Users\aag\Documents\Python\test.py", line 7, in <module>
        x.add_row(row)
          File "C:\Python33\lib\site-packages\prettytable.py", line 817, in add_row
        if self._field_names and len(row) != len(self._field_names):
    TypeError: object of type 'int' has no len()
    

I am sure that I am doing something unspeakably stupid, but I do not know what
that is. Might a kind soul orient me towards the right direction?


Answer: According to [the
documentation](http://code.google.com/p/prettytable/wiki/Tutorial), `add_row`
is expecting a `list`, _not an`int`_, as an argument. Assuming that you want
the values in `arrayHR` to be the first value in each row, you could do:

    
    
    x = PrettyTable(["Heart Rate"])
    for row in arrayHR:
        x.add_row([row])
    

or adopt the `add_column` example, also from the documentation:

    
    
    x = PrettyTable()
    x.add_column("Heart Rate", arrayHR)
    

