pythonds icon indicating copy to clipboard operation
pythonds copied to clipboard

Code returning a different result on runestone vs local

Open irunestone opened this issue 5 years ago • 1 comments

Error reported in course pythonds on page GettingStartedwithData by user UPS [email protected] In the following code when we print(A) after changing the element in myList - A shows the new value whereas if I run the same code on my local or an online REPL, it prints the same value as before for A

myList = [1,2,3,4] A = [myList]*3 print(A) myList[2]=45 print(A)

Output in runestone: [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]] [[1, 2, 45, 4], [1, 2, 45, 4], [1, 2, 45, 4]]

Output in local: [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4] [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]

irunestone avatar Apr 12 '19 14:04 irunestone

I'm not sure what you are using for your local python, but I get the same output in both 2.7.10 and 3.7 on my local copies of Python. I think you are doing something different on your local python as you will notice that you are not getting the correct result of 3 lists to start with.

bnmnetp avatar Apr 12 '19 15:04 bnmnetp