Am 05.07.16 um 10:22 schrieb Steven D'Aprano:
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]
and after that, try:
>>> a=[0]
>>> t=(a,)
>>> a+=[1]
Christian
--
https://mail.python.org/mailman/listinfo/python-list