Skip to main content

Python: Update Tuple

As we know tuples are immutable. Thus when the tuple is created we cannot change its value or update its value However we can workaround  by firstly , converting  tuple to list by built-in function list(). As we know, we can always update an item to list object assigning new value to element at certain index. Then use another built-in function tuple() to convert this list object back to tuple.


tup = (10,20,30,40,50)
list_1 = list(tup)
list_1[0] = 5
tup = tuple(list_1)

Output: (5, 20, 30, 40, 50)

Submitted by devanshi.srivastava on June 12, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.