Programming with Python

⌘K
  1. Home
  2. Docs
  3. Programming with Python
  4. List, Tuples and Dictiona...
  5. Tuples
  6. Tuples are Immutable

Tuples are Immutable

Introduction:

  • Tuples are immutable
  • The values or items in the tuple cannot be changed once it is declared.
  • To change the values in the tuple, one have to create a new tuple

Example:

#create a tuple
>>> a=(4,6,2,4)
>>> a
(4, 6, 2, 4)
#change the value at 2nd postion
>>> a[2] = 100
TypeError: 'tuple' object does not support item assignment

Views: 2

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments