python - Storing every value of a changing variable -


i writing piece of code takes input varies according discrete time steps. each time step, new value input. how can store each value list?

here's example:

"""when t = 0, d =    when t = 1, d = b    when t = 2, d = c"""  n = [] n.append(d)      #d changing variable in range(t):     n.append(d) 

what expect is: for t = 0, n = [a]; t = 1, n = [a,b]; , t = 2, n = [a,b,c]

what is: for t = 0, n = [a], t = 1, n = [b,b]; , for t = 2, n = [c,c,c]

see comment below, based on additional info you've provided, replace this:

n.append(d) 

with this:

n.append(d[:]) 

Comments