def ingredients(recipes,menu):
storage = []
empty_lst =[]
inner = []
count = 0
z = 0
n = len(recipes)
menu_row = recipes[0]
for _ in menu:
for i in range(len(menu_row)):
if _ == menu_row[i]:
storage.append(menu_row.index(menu_row[i]))
for j in range(1,n):
for a in range(len(storage) - 1):
empty_lst.append([recipes[j][0]] + [recipes[j][storage[a]] + recipes[j][storage[a + 1]]])
return empty_lst
recipes = [[None,'cake','scrambled eggs','hot tea'],
['eggs',2, 4, 0 ],
['milk',2, 0.5, 1 ],
['bread',0, 1, 0 ],
['tea', 0, 0, 2 ],
['sugar',1.5, 0, 0.25 ],
['flour',4, 0, 0 ]]
menu = ['cake','hot tea']
print(ingredients(recipes,menu))