How to create a number of empty nested lists in python [duplicate]
问题 This question already has an answer here: List of lists changes reflected across sublists unexpectedly 13 answers I want to have a variable that is a nested list of a number of empty lists that I can fill in later. Something that looks like: my_variable=[[], [], [], []] However, I do not know beforehand how many lists I will need, only at the creation step, therefore I need a variable a to determine it. I thought about simple my_variable=[[]]*a , but that creates copies of lists and it is not