print(b) will print the original copy of a which b now references which is [1, ["x", "y"], 3] On Apr 18, 2015 7:50 AM, "Peter Otten" <__pete...@web.de> wrote:
> Bill Allen wrote: > > > Everyone that responded, > > > > Thanks very much for the excellent explanations! The distinction between > > a reference to an object and a seperate copy of the object is quite clear > > now. > > You can test your newfound knowledge by predicting the output of the > following script: > > > a = [1, ["x", "y"], 3] > b = a[:] > > a[1][1] = "hello!" > > print(a) # [1, ['x', 'hello!'], 3] > print(b) # what will that print? > > Think twice before you answer. What is copied, what is referenced? > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor