Dictionary problem

Elena Schulz elena.schulz at gmx.net
Mon Nov 17 11:35:55 EST 2003


Hi,

I've the following code:

myList = []
for i in range(3) :
    myDict['id']=i
    myList.append(myDict)

myList becomes: [{'id':2}, {'id':2}, {'id':2}] but I want: [{'id':0},
{'id':1}, {'id':2}]

thanx for any hint how to achieve that

-- Greetings, Elena

(Please answer to my mail address directly as I am currently not subscribed
to this list, thanks)






More information about the Python-list mailing list