[[]]*2
is a list of two references to the same list. You are appending to it and then seeing it twice.
More Related Contents:
- How to make a dict from n’th indices of tuples in list
- Why does this code for initializing a list of lists apparently link the lists together? [duplicate]
- Python list doesn’t reflect variable change
- Why is [] faster than list()?
- How can I multiply all items in a list together with Python?
- Remove trailing newline from the elements of a string list
- How to loop through all but the last item of a list?
- Writing a list to a file with Python, with newlines
- How can I convert each item in the list to string, for the purpose of joining them? [duplicate]
- How can I initialize a dictionary of distinct empty lists in Python?
- Take the content of a list and append it to another list
- Modifying a list inside a function
- Python: How to remove empty lists from a list? [duplicate]
- How to get the n next values of a generator in a list (python)
- Merging/adding lists in Python
- How do I sort this list in Python, if my date is in a String?
- Convert all strings in a list to integers
- “TypeError: ‘type’ object is not subscriptable” in a function signature
- How can I convert string values from a dictionary, into int/float datatypes?
- python – get list of tuples first index?
- Python: Elegant and efficient ways to mask a list
- Optimal method to find the max of sublist items within list
- Find a value in a list [duplicate]
- How do I send list of dictionary as Body parameter together with Files in FastAPI?
- Creating a list in Python- something sneaky going on?
- Rearranging list based on order of another list
- list comprehension with multiple conditions (python)
- How to convert only numbers in a mixed list into float
- In what case would I use a tuple as a dictionary key? [closed]
- deque.popleft() and list.pop(0). Is there performance difference?