Continuing in IDLE, assign a dictionary's keys to two variables, and then
change one of them like this:
d = dict(november=11, oscar=12, papa=13, quebec=14)
v1 = v2 = d.keys()
v1, v2 # This will show the contents of the lists
v1[3] = "X"
After this, do you expect v1 and v2 to be the same or different? Why? Print
out v1 and v2 to see. Now try assigning to v1 and v2 separately, and again
change one:
v1 = d.keys()
v2 = d.keys()
Will v1 and v2 be the same as before? Print them out to see. If any of this is
mysterious try re-reading the sidebar on page 33.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here