insert mydict into mylist's third position for 4 times, where the name should increment (e.g: x1,x2,x3..)
mylist=["a","b","c","d"]
mydict={'name':"x"}
for i in range(1,5):
mydict['name']="x"+str(i)
mylist.insert(2,mydict)
print(mylist)
Expected output:
['a', 'b', {'name': 'x4'}, {'name': 'x3'}, {'name': 'x2'}, {'name': 'x1'}, 'c', 'd']
Actual output:
['a', 'b', {'name': 'x4'}, {'name': 'x4'}, {'name': 'x4'}, {'name': 'x4'}, 'c', 'd']