Posted on 10th September 2024| views
Python tuple is an immutable object which means we cannot change it or we cannot append it, but there is an alternative way, by using the built-in list() function convert the tuple into the list. You can append the list objects then again convert the list object into tuple object by using tuple(). Here is the example
Tu=(10,50,20)
>>> Li=list(Tu)
>>> Li
[10, 50, 20]
>>> Li.append(80)
>>> Tu=tuple(Li)
>>> Tu
(10, 50, 20, 80)