Basic Tuple Operations
Learn about the basic tuple operations in Python.
We'll cover the following...
Some basic tuple operations are given below.
Mutability
Unlike a list, a tuple is immutable, i.e., it cannot be modified.
Press + to interact
msg = ('Fall', 'In', 'Line')msg[0] ='FALL' # errormsg[1:3] = ('Above', 'Mark') # error
Note: Since a tuple is immutable, operations like
append()
,remove()
, andinsert()
do not work with a tuple.
Though a tuple itself is immutable, it can contain mutable objects like lists.
...