I'm not entirely sure what you're trying to do here but random.randint(0,1) only ever returns 0 or 1. Therefore, like flipping a coin, sometimes you'll get a series of 1's or a series of 0's and sometimes they'll alternate but they will never be anything other than 0 or 1.

emh, well, yea, that randint(0,1) is representing whether an item is brought or not. I mean, this is the parent in parentList which is similar each other(to reduce unsignificant data, I only print the 'brought' value of each parent)

data and li[i] are just different names for the same dictionary.If you modify data, li[i] is also modified.

When appending to a, you're creating another name(a[i]) for that, now modified, dictionary.You then return a.

Each time you call the generateParent() function, you're creating a new a list.The new list will contain the dictionaries a[0], ..., a[6].But, as I just explained, a[i] is just a different name for li[i].

So, all the lists you created contain li[0], ..., li[6].Even though you created 5 new lists, all of them contain the exact same dictionaries.

I hope now you understand what the problem is, and that it will bring you closer to a solution.

One possibility is creating a new dict, instead of assigning li[i] and changing it.There are a few ways to do this, but probably the easiest is to use dict.copy()