You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
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.
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]
The text was updated successfully, but these errors were encountered: