list1 = [set(), set(), set()]
list2 = [set() for _ in range(3)]
print(list1 == list2)
results in true
However, they seem to differ.
I was solving this problem: https://leetcode.com/problems/valid-sudoku/
Using the following does not work:
rows = [set()] * 9
cols = [set()] * 9
boxes = [set()] * 9
But replacing that with:
rows = [set() for _ in range(9)]
cols = [set() for _ in range(9)]
boxes = [set() for _ in range(9)]
makes the code work. I'm very confused as to what the difference is and how there could even be a difference if they are equal.