This is what I want when N=2
lists = [[], []]
print(lists) # [[], []]
lists[0].append(5)
print(lists) # [[5], []]
But, I don't want to repeatedly type N empty lists in the first statement. So, I tried this:
N = 2
lists = [[]] * N
print(lists) # [[], []]
lists[0].append(5)
print(lists) # [[5], [5]]
I don't understand the behavior displayed by the print above. Please explain the behavior above on creating a list with multiple elements using "*". And of course, I'd like to know how to do this correctly