Insert a value into dict of nested lists

Viewed 48

Here i want insert a value into dictionary of nested lists. This is what I'm tried,

company_ids = [1,2,3]   
seller_ids = [[0, False, { u'company_id': 4}]]
result = []
for company in company_ids:
    for i in xrange(0, len(seller_ids)):
        seller_ids[i][2]['company_id'] = company
        result.append(seller_ids[i])
print result

I'm getting this

[[0, False, {u'company_id': 3}],
 [0, False, {u'company_id': 3}],
 [0, False, {u'company_id': 3}]]

But I'm expecting this,

[[0, False, {u'company_id': 1}],
 [0, False, {u'company_id': 2}],
 [0, False, {u'company_id': 3}]]

Please help me solve this. Thanks in advance...

2 Answers
Related