Tuple is immutable list. Once a tuple has been created, it cannot be changed in any way.
The same as the Tuple and list
A tuple is defined in the same way as a list, except that the entire set of elements is surrounded by parentheses rather than square brackets.
The elements of a Tuple are sorted in the order defined by the list. The tuples index is the same as list starting from 0, so the first element of a non-empty tuple is always t[0].
A negative index is counted as a list from the tail of a tuple.
As with list shards (slice) can also be used. Note that when a list is split, a new list is obtained, and when a tuple is split, a new tuple is obtained.
A method that does not exist for a Tuple
You cannot add elements to a tuple. The Tuple does not have a append or extend method.
You cannot delete an element from a tuple. The Tuple does not have a remove or pop method.
You cannot find elements in a tuple. Tuple does not have an index method.
However, you can use in to see if an element exists in a tuple.
Benefits of using Tuple
A Tuple operates faster than a list. If you define a constant set of values and the only thing you want to do with it is to iterate over it, use tuple instead of list.
You can make your code more secure if you write-protect the data that you do not need to modify. Using a tuple instead of a list is like having an implied Assert statement, which indicates that the data is a constant. If you have to change these values, you need to perform a tuple-to-list conversion.
Conversion of Tuple to list
A Tuple can be converted into a list and vice versa. The built-in tuple function receives a list and returns a tuple with the same element. The list function receives a tuple and returns a list. In effect, a tuple freezes a list, and the list thaws a tuple.