I'm stuck in a problem in Python. I want to add a list of variables to a list in order to have multiple lists, this way (it's an example):
legal = [1, 2, 3, 4, 5]
state = [0, 9]
for p in legal:
new = state
new.append(p)
print(new)
Output I have with this code:
[0, 9, 1]
[0, 9, 1, 2]
[0, 9, 1, 2, 3]
[0, 9, 1, 2, 3, 4]
[0, 9, 1, 2, 3, 4, 5]
Output I look for:
[0, 9, 1]
[0, 9, 2]
[0, 9, 3]
[0, 9, 4]
[0, 9, 5]
Is there a way to keep the original list without redefining it in the loop?