Q:

How to create multidimensional array in python from list?

I have a list containing elements like 
list1 = [['Test Name', 'Results', 'Units', 'Bio. Ref. Interval'], 
         ['Cholesterol, Total', '243.00', 'mg/dL', '<200.00'], 
         ['Triglycerides', '365.00', 'mg/dL', '<150.00'], 
         ['HDL Cholesterol', '48.56', 'mg/dL', '>50.00'], 
         ['LDL Cholesterol, Calculated', '121.44', 'mg/dL', '<100.00'], 
         ['VLDL Cholesterol, Calculated *', '73.00', 'mg/dL', '<30.00'], 
         ['Non-HDL Cholesterol', '194', 'mg/dL', '<130']]

I want to use list1[0] that is, ['Test Name', 'Results', 'Units', 'Bio. Ref. Interval'] to make it as key and want output something like the following multidimensional dictionary.
{
 { Testname : 'Cholesterol, Total' {
                        Result : '243.00',
                        Units :  'mg/dL',
                        Bio. Ref. Interval : '<200.00'
                    },....
  ....
 { Testname : 'Non-HDL Cholesterol' { Result : '194', Units : 'mg/dL', Bio. Ref. Interval : '<130'}}
}

I'm newbie to python. Help out please.

A:

You need unique keys for the dictionary so you can do something like this:
dict1 = {f'Test {j}': {list1[0][i]: list1[j][i] for i in range(4)} for j in range(1, len(list1))}

Which will have the following output.
{'Test 1': {'Test Name': 'Cholesterol, Total', 'Results': '243.00', 'Units': 'mg/dL', 'Bio. Ref. Interval': '<200.00'},
 'Test 2': {'Test Name': 'Triglycerides', 'Results': '365.00', 'Units': 'mg/dL', 'Bio. Ref. Interval': '<150.00'},
 'Test 3': {'Test Name': 'HDL Cholesterol', 'Results': '48.56', 'Units': 'mg/dL', 'Bio. Ref. Interval': '>50.00'},
 'Test 4': {'Test Name': 'LDL Cholesterol, Calculated', 'Results': '121.44', 'Units': 'mg/dL', 'Bio. Ref. Interval': '<100.00'},
 'Test 5': {'Test Name': 'VLDL Cholesterol, Calculated *', 'Results': '73.00', 'Units': 'mg/dL', 'Bio. Ref. Interval': '<30.00'},
 'Test 6': {'Test Name': 'Non-HDL Cholesterol', 'Results': '194', 'Units': 'mg/dL', 'Bio. Ref. Interval': '<130'}}

