cols = ['id', 'name', 'pass']
old_list = [[1, 'вася', '123'],[2,'mike','321'],[3,'john','password']]
g_dict = []
for i in old_list:
g_dict.append(i)
new_dict = dict(zip(cols, g_dict))
{
'id': [1, 'вася', '123'],
'name': [2, 'mike', '321'],
'pass': [3, 'john', 'password']
}
cols = ['id', 'name', 'pass']
old_list = [[1, 'вася', '123'],[2,'mike','321'],[3,'john','password']]
g_dict = []
for item in old_list:
g_dict.append(dict(zip(cols, item)))
cols = ['id', 'name', 'pass']
old_list = [[1, 'вася', '123'],[2,'mike','321'],[3,'john','password']]
g_dict = [dict(zip(cols, item)) for item in old_list]