How to Append Value Insert Value Modify or Replace Delete Value in tuple using Python With Example
In This Post How to Append Value Insert Value Modify or Replace Delete Value in tuple using Python With Example
Program Code Example:
#How to Append Insert Modify/Replace Delete item in tuple using
Python 3
tup = ('Adnan','Ashir','Hafeez','Mubashir')
print(tup)
#Append Element in tuple in the last of tuple
tup = tup + ('Abdullah',)
print(tup)
#Insert new value in tuple in a specific Index using python (at
index 2)
i = 2
tup = tup[ :i] + ("Safdar",) + tup[i:
]
print(tup)
# Modify or Replace item at specific index in Tuple (modify
value index 3)
i = 3
tup = tup[ :i] + ('Danial',) + tup[i+1 : ]
print(tup)
# Delete Item at Specific index in Tuple (Index 4 value delete)
i = 4
tup = tup[ :i] + tup[i+1 : ]
print(tup)
Post a Comment