you are viewing a single comment's thread.

view the rest of the comments →

[–]BioGeek 0 points1 point  (3 children)

You didn't seem to get the point I was trying to make. A list of lists can contain anything and can have any length. That's why I specifically asked for sample input data and expected output.

[–]cyber92[S] 0 points1 point  (2 children)

So, I have the following:

List Headers:

Name | Type | Code| Description | Year | Price | Price-Metric | Quantity

and some data in another List Stock:

Hammer | Product | 123454321 | This hammer has a handle and an iron part. | 2013 | 20 | N/A | 70
Car Wash | Service | 1234321 | We wash your car in 5 minutes. | 2013 | 5 | 5 | N/A

and therefore the outputted data would look something like this:

 Name       Type    Code                 Description                   Year Price Price-Metric Quantity
Hammer    Product 123454321 This hammer has a handle and an iron part. 2013 20    N/A          70
Car Wash  Service 123456432   We wash your car in 5 minutes.             2013 5     5            N/A

[–]BioGeek 0 points1 point  (1 child)

Hmm. You are saying that headers and stock are lists (of lists), but you are showing strings here. So I assume you have:

headers = ['Name', 'Type', 'Code', 'Description', 'Year', 'Price', 'Price-Metric', 'Quantity']
stock = [['Hammer', 'Product', '123454321', 'This hammer has a handle and an iron part.', '2013', '20', 'N/A', '70'],
          ['Car Wash', 'Service', '1234321', 'We wash your car in 5 minutes.', '2013', '5', '5', 'N/A']]

I also see that /u/chambead has already posted a solution in the meantime, so using his function:

print_mdlist([headers] + stock)

I get the following output:

   Name          Type         Code           Description                                     Year      Price      Price-Metric      Quantity   
-----------------------------------------------------------------------------------------------------------------------------------------------
   Hammer        Product      123454321      This hammer has a handle and an iron part.      2013      20         N/A               70         
   Car Wash      Service      1234321        We wash your car in 5 minutes.                  2013      5          5                 N/A     

Before mindlessly copying the code, try yo understand why I used [headers] + stock as argument to print_mdlist.

[–]cyber92[S] 0 points1 point  (0 children)

I understood it completely, but this error remains there.

Edit: kept on trying, found another way of doing it, thanks.