Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Table creating code
#1
hi all,
below is the code posted by me. I am getting the error of undefined token for the tabulate code while printing it in visual studio.
Kindly help with the modification.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from tabulate import tabulate
 
people_array = list()
people = input("How many people ordered?  ")
print("Enter people and their orders in list:")
 
a=[]
b=[]
c=[]
 
 
for i in range(int(people)):
    p = str(input("Person :"))
    o1 = str(input("Apple Cider ordered by",p," :"))
    o2 = str(input("Apple juice orderd by",p, " :"))
 
    a.append(p)
    b.append(o1)
    c.append(o2)
 
print tabulate(a,b,c,headers=["Name","AC","AJ"])
 
 
    #print(a ,"\n", b ,"\n", c ,"\n")
#print(q,w)
Reply
#2
You must use a list of lists as the first parameter:
1
print(tabulate([a,b,c],headers=["Name","AC","AJ"])
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Multiplication Table code alexsendlegames100 3 2,370 Jun-06-2022, 09:45 AM
Last Post: Gribouillis
  Creating table in MySQL db with decimal number issue dangermaus33 7 7,605 Nov-20-2020, 10:40 PM
Last Post: dangermaus33
  Creating a table in SQLite3 djwilson0495 2 2,783 Aug-10-2020, 03:01 PM
Last Post: djwilson0495
  Python code for exporting table using Selenium gj31980 4 4,867 Aug-04-2020, 01:29 AM
Last Post: gj31980
  Code import .CSV file to MySQL table rtakle 4 3,947 Apr-30-2020, 03:16 PM
Last Post: anbu23
  Approach to creating Audit table pynewbie 4 5,222 Feb-24-2020, 06:12 PM
Last Post: pynewbie
  Creating a delimited file from DB Table anubhav2020 9 10,092 Sep-19-2018, 05:22 PM
Last Post: Axel_Erfurt
  Creating a table from a dataset anthonylauly 2 3,637 May-29-2018, 04:01 AM
Last Post: anthonylauly
  Python code to check SQL table for current date PYTHONDUDE 3 3,914 May-16-2018, 02:27 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020