I am currently iterating through one value of a list. On each iteration, I append the list to a new list, in order to have a list of lists. However, the outputs that I am receiving aren't what I am expecting them to be.
I've simplified the problem as much as possible and have arrived at this :
def Function():
ListOfLists = []
Lists = [0]
for j in range(0, 5):
Lists[0] = Lists[0] + 1
print(Lists)
ListOfLists.append(Lists)
print("ListofLists:")
print(ListOfLists)
Function()
The output gives me this :
[1]
[2]
[3]
[4]
[5]
ListofLists:
[[5], [5], [5], [5], [5]]
I would've expected the output to be :
[1]
[2]
[3]
[4]
[5]
ListofLists:
[[1], [2], [3], [4], [5]]
Where am I going wrong? Thanks