kaushalshriyan at gmail.com
Tue Apr 11 11:19:37 CEST 2006
I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap09.htm
>>> tuple = ('a', 'b', 'c', 'd', 'e')
And the slice operator selects a range of elements.
But if we try to modify one of the elements of the tuple, we get a error:
>>> tuple = 'A'
TypeError: object doesn't support item assignment
Of course, even if we can't modify the elements of a tuple, we can
replace it with a different tuple:
>>> tuple = ('A',) + tuple[1:]
('A', 'b', 'c', 'd', 'e')
How does tuple = ('A',) + tuple[1:] this work ????
Please explain me with an example
More information about the Tutor