pip install tabulate
from tabulate import tabulate
table = [[‘class’ , ‘var’ , ‘1’],
[‘cat’ , ‘dog’ , ‘2’],
[‘aa’ , ‘bb’ , ‘3’]]
print(tabulate(table))
When I run it I get:
C:\Users\Han\anaconda3\python.exe C:\Users\Han\PycharmProjects\pythonProject\clipboard1.py
File “C:\Users\Han\PycharmProjects\pythonProject\clipboard1.py”, line 1
pip install tabulate
^
SyntaxError: invalid syntax
Process finished with exit code 1
What did I do wrong? Trying to make columns out of lists.
jrivers
(J. Rivers)
May 14, 2023, 8:26pm
2
The line that says:
pip install tabulate
does not go in your program. That’s a command that you run separately, before you run your program, which will download and install the tabulate
package on your computer. This is where the module that you import in this line:
from tabulate import tabulate
at the beginning of your program, comes from.
Oh, I get it. I had to choose one or the other, not both. Now it works. Thanks
Thanks. I had to choose one or the other, i get it. Now it works