How to Change Tuple Values in Python


In this example, we will learn how to change tuple values in Python.

Source Code

tuple1 = ('a', 'b', 'c', 'd')

list1 = list(tuple1)    # convert the tuple into a list to be able to change it

list1[2] = 1

tuple2 = tuple(list1)    # convert the list into a tuple

print(tuple2)

Output:

('a', 'b', 1, 'd')
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement