List comprehension vs multiplying a list differences?
Is there any difference between the following code?:

    arr = [[]] * 10
    arr = [[] for x in range(10)]

I used the first method to initiate a list on a hackerank problem and I kept getting wrong answer. When I googled the answer and saw the person use the second method, so I tried it and got the right answer?? `[[]] * 10 == [[] for x in range(10)]` returns True. Why would the way I initiate this list cause a different result?

If anyone wants to try it themselves.. it's a real head scratcher for me.

[https://programs.programmingoneonone.com/2021/05/hackerrank-dynamic-array-solution.html](https://programs.programmingoneonone.com/2021/05/hackerrank-dynamic-array-solution.html)  


    def dynamicArray(n, queries):
        # Write your code here
        arr = [[] for x in range(n)]
        #Now try using the code below to initiate arr. This fails it for me.
        #arr = [[]] * n
        lastAnswer = 0
        answers = []
        for x in queries:
            idx = (x[1]^lastAnswer) % n
            if x[0] == 1:
                arr[idx].append(x[2])
            else:
                lastAnswer = arr[idx][x[2] % len(arr[idx])]
                answers.append(lastAnswer)
        return answers