Important Notice:

Tuple as an Immutable Data Type

Tuple as an Immutable Data Type

1 views 1 min read
Tuple as an Immutable Data Type :-

Python में Tuple एक Immutable Data Type है। इसका मतलब है कि Tuple बनने के बाद हम उसके elements को change, add या remove नहीं कर सकते।

Example
 
numbers = (10, 20, 30)

numbers[1] = 50

print(numbers)

Output:

TypeError: 'tuple' object does not support item assignment

यहाँ 20 को बदलकर 50 करने का प्रयास किया गया, लेकिन Tuple के elements को change नहीं किया जा सकता। इसलिए Tuple को Immutable Data Type कहा जाता है।

In english-

Tuple as an Immutable Data Type

In Python, Tuple is an Immutable Data Type. This means that after a Tuple is created, we cannot change, add, or remove its elements.

Example
numbers = (10, 20, 30)

numbers[1] = 50

print(numbers)
 
Output:
TypeError: 'tuple' object does not support item assignment

Here, an attempt is made to change 20 to 50, but the elements of a Tuple cannot be changed. Therefore, a Tuple is called an Immutable Data Type.

Related Notes