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)]
More Related Contents:
- How to perform element-wise multiplication of two lists?
- How can I multiply all items in a list together with Python?
- Multiply operator applied to list(data structure)
- How to multiply all integers inside list [duplicate]
- convert string to list [duplicate]
- Unable to use convert strings into integers for a for loop
- Strange result when removing item from a list while iterating over it
- How to merge lists into a list of tuples?
- Pythonic way to print list items
- Count frequency of words in a list and sort by frequency
- In Python, what is the difference between “.append()” and “+= []”?
- Different ways of clearing lists
- How to get item’s position in a list?
- Add list to set
- How to find the min/max value of a common key in a list of dicts?
- str.startswith with a list of strings to test for
- How to split strings inside a list by whitespace characters
- Complexity of list.index(x) in Python
- How to transform string of space-separated key,value pairs of unique words into a dict
- Nested list comprehensions
- Python range() and zip() object type
- How do I merge multiple lists into one list? [duplicate]
- Group list by values [duplicate]
- Python: filtering lists by indices
- What are dict_keys, dict_items and dict_values?
- Ordered intersection of two lists in Python
- What to consider before subclassing list?
- Counting depth or the deepest level a nested list goes to
- Which is the most efficient way to iterate through a list in python?
- How does str.startswith really work?