I need to create array/dictionaries in python based on an array which contains keys. I found an equivalent solution in PHP. Unfortunately I don't know how I can implement this in Python. Can somebdoy give me any tips?
a = ['one', 'two', 'three']
b = ['one', 'four', 'six']
I want to get the following result:
c = {'one': {'two': 'three', 'four': 'six}}
The PHP solution uses references for that. Perhaps this is a better example:
ar[0] = ['box0', 'border0', 'name']
var[1] = ['box0', 'border0', 'type']
var[2] = ['box0', 'border1', 'name']
var[3] = ['box1', 'border2', 'name']
var[4] = ['box1', 'border0', 'color']
$val = 'value'
In PHP the result would look like:
$result = array(
'box0' => array(
'border0' => array('name' => $val, 'type' => $val, 'color' => $val),
'border1' => array('name' => $val),
),
'box1' => array(
'border0' => array('color' => $val),
'border2' => array('name' => $val)
)
) );