New submission from Leonardo <leonardo.simuno...@gmail.com>:
in this code the variable o changes on its own: x=[[-1, 7, 3], [12, 2, -13], [14, 18, -8], [17, 4, -4]] x1=[[-8, -10, 0], [5, 5, 10], [2, -7, 3], [9, -8, -3]] y=[[0,0,0],[0,0,0],[0,0,0],[0,0,0]] k=True f=0 z=[] d=[] while k: print(k) o=x print(o) for i in range(len(x)): for n in range(len(x)): if i!=n: for g in range(3): if x[i][g]>x[n][g]: y[i][g]-=1 if x[i][g]<x[n][g]: y[i][g]+=1 for i in range(len(x)): for n in range(3): x[i][n]+=y[i][n] for i in range(len(z)): if z[i]==x and d[i]==y: print("") print(o) k=False A similar error happens when I try to append x values to a list, the list is filled with the same x value (the last one that has been appended) the number of times a x value had been appended in general. For example: if I had a values of x at the end of the while loop as 1, 2 and 3 and I appended them to a list the list would be [3, 3, 3] instead of [1, 2, 3]. If i wrote the list out each time a new x value is appended it would write it [1] first, then [2, 2] and then [3, 3, 3] at the end. I am really sorry for wasting time if this is just me being really dumb and messing something up. ---------- assignee: terry.reedy components: IDLE messages: 358790 nosy: leonardo.simuno...@gmail.com, terry.reedy priority: normal severity: normal status: open title: Variables changing values on their own type: behavior versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39118> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com