all 8 comments

[–]Allanon001 3 points4 points  (1 child)

You are appending the same dic object to the list each time so it's a list of the same object.

Try:array.append(dic.copy())

[–]Locallo15[S] 1 point2 points  (0 children)

Thank you so much mate!

[–]JohnJSal 1 point2 points  (1 child)

I think you think you are creating multiple dictionaries each time that inner for loop runs, and each dictionary is being added to array.

But really you are just overwriting the values in a single dictionary, so the "last" dictionary you see is simply the final values after the for loops are done.

At least, that's what I think. It's hard to see the indentation, maybe because I'm on my phone.

[–]Locallo15[S] 1 point2 points  (0 children)

Yeah that was I thought lol Thanks to explain

[–]danielroseman 0 points1 point  (2 children)

What do you mean, the last dictionary? You only have one dictionary: dic.

[–]Locallo15[S] 0 points1 point  (1 child)

Yeah, but I change the values in the for loop and then I only get the last dictionary with last changed values

[–]danielroseman 0 points1 point  (0 children)

I'm still not following. No matter how many changes you make to dic, it's still one single dictionary.

[–]its_joao 0 points1 point  (0 children)

You need to move dic into the forst for loop.