added example for immutability for consistency as in other data structure descriptions (#19260)

Other immutable data structures have examples to show immutability which is missing in tuple description which makes it look inconsistent
This commit is contained in:
Vivek Soundrapandi
2018-10-16 09:49:28 +05:30
committed by Quincy Larson
parent e36832b1ca
commit 58bef02dbb

View File

@@ -5,6 +5,12 @@ title: The Tuples
A tuple is a sequence of Python objects. Tuples are immutable which means they cannot be modified after creation, unlike lists.
>>> tuple = (1,2,3)
>>> tuple[1] = 4
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'tuple' object does not support item assignment
**Creation:**
An empty `tuple` is created using a pair of round brackets, `()`: