Issue 28594: List define and Change result (original) (raw)
Hi, I define multi List in a line such as this: smoke= exercise = cholesterol = angina = stroke = attack = [0] * 2 and This work bad! if I define later line such this, problem has been solve: smoke=[0]*2 exercise = [0]*2 cholesterol = [0]*2 angina = [0]*2 stroke = [0]*2
I just change this line in my project but result changed!
Is this a bug?
notice to "Smoke" change in follow, "Smoke" changed from [0, 1] to [0 ,6] in a one state, for what??!!
out put before change:
$ python3.5 ./my.py smoke= [0, 0] before income: [0, 0, 0, 0, 0, 0, 0, 0] income[ 5 ] += 1 after income: [0, 0, 0, 0, 0, 1, 0, 0] before smoke: [0, 0] 2 smoke[ 1 ] += 1 after smoke: [0, 1] stop in step before income: [0, 0, 0, 0, 0, 1, 0, 0] income[ 1 ] += 1 after income: [0, 1, 0, 0, 0, 1, 0, 0] before smoke: [0, 6] 2 smoke[ 1 ] += 1 after smoke: [0, 7] stop in step before income: [0, 1, 0, 0, 0, 1, 0, 0] income[ 5 ] += 1 after income: [0, 1, 0, 0, 0, 2, 0, 0] before smoke: [2, 10] 1 smoke[ 0 ] += 1 after smoke: [3, 10] stop in step
out put after change:
$ python3.5 my1.py smoke= [0, 0] before income: [0, 0, 0, 0, 0, 0, 0, 0] income[ 5 ] += 1 after income: [0, 0, 0, 0, 0, 1, 0, 0] before smoke: [0, 0] 2 smoke[ 1 ] += 1 after smoke: [0, 1] stop in step before income: [0, 0, 0, 0, 0, 1, 0, 0] income[ 1 ] += 1 after income: [0, 1, 0, 0, 0, 1, 0, 0] before smoke: [0, 1] 2 smoke[ 1 ] += 1 after smoke: [0, 2] stop in step before income: [0, 1, 0, 0, 0, 1, 0, 0] income[ 5 ] += 1 after income: [0, 1, 0, 0, 0, 2, 0, 0] before smoke: [0, 2] 1 smoke[ 0 ] += 1 after smoke: [1, 2] stop in step
:/
Thanks
Thank for attention,but see this:
x=y=[] x=y=[0]*3 x [0, 0, 0] y [0, 0, 0] y=[0, 1, 1] x [0, 0, 0] y [0, 1, 1] y[1]+=1 y [0, 2, 1] x [0, 0, 0] x[0]+=5 x [5, 0, 0] y [0, 2, 1]
then must my code work and there is another problem :/
notice: I don't write like this:
x=[] y=x