HowtoBecomeaProgrammer
About UsContact UsA tuple is considered a type of array, which consists of dictionaries, lists, sets, and tuples, and are in many ways similiar to lists. However, there are a few key differences between the two. The most obvious is that tuples use parenthesises rather than brackets when enclosing data. They are also considered immutable, aka unchangeable, so once they are set, you can not change or add any data.
a_tuple = (1, 2, 3)
print(a_tuple)
a_tuple[0] = 4
First, we create a tuple that contains 1, 2, 3. Then we print the tuple out, then we try to reassign the first element to 4, however that brings up in error because as stated early tuples are immutable.
Tuples, just like lists can be created using the tuple() function. The main reason for using a tuple over a list is if you want the data stored in the tuple to be stored forever, and the only way to "change" the data is by using the del keyword to get rid of the tuple completly.