You’ve made 3 references to the same list.
>>> a = b = []
>>> a.append(42)
>>> b
[42]
You want to do this:
P = [[()] * 3 for x in range(3)]
You’ve made 3 references to the same list.
>>> a = b = []
>>> a.append(42)
>>> b
[42]
You want to do this:
P = [[()] * 3 for x in range(3)]