(question)
Question:
Answer:
Question:
#!/usr/bin/python
a = ([1,2,3], [7,8,9])
try:
a[0] += [4,5,6]
except Exception, e:
print "Error: %s" % e
print "a=%s" % str(a)
Output:
Python manages to modify the [1,2,3] list in-place, but then it fails after making the changes, because tuples are not mutable.Error: object doesn't support item assignment a=([1, 2, 3, 4, 5, 6], [7, 8, 9])