I have the following lists:
brand=["Audi","Mercedes"]
speed=[130,150]
model=["sport","family"]
I want to obtain the equivalent of:
ll=[]
ll.append({'brand':'mercedes', 'speed':130, 'model':'family'})
ll.append({'brand':'mercedes', 'speed':130, 'model':'sport'})
ll.append({'brand':'audi', 'speed':130, 'model':'family'})
ll.append({'brand':'audi', 'speed':130, 'model':'sport'})
ll.append({'brand':'mercedes', 'speed':150, 'model':'family'})
ll.append({'brand':'mercedes', 'speed':150, 'model':'sport'})
ll.append({'brand':'audi', 'speed':150, 'model':'family'})
ll.append({'brand':'audi', 'speed':150, 'model':'sport'})
I currently do:
from itertools import product
ll=list(product(speed, model, brand))
I have all needed combinations but this is simply a list of list and not a list of dictionary. I don't know if there is a direct and pythonic way to do it!