On Tuesday 05 July 2016 16:38, Chris Angelico wrote: > On Tue, Jul 5, 2016 at 4:33 PM, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: >> What happens in this code snippet? >> >> L = [1] >> t = (L,) >> t[0] += 1 >> >> Explain what value t has, and why. > > Not sure you have that question right, because it simply gives a > TypeError. You can't add an integer to a list.
D'oh! Try this instead: t = ([0],) t[0] += [1] -- Steve -- https://mail.python.org/mailman/listinfo/python-list