A tuple is a data structure that's similar to a list: both are used to store multiple values in a single variable. In practice, lists are typically homogeneous (storing values of a single type), while tuples may be heterogeneous (storing values of multiple types). Take a look:
user_data = 'John', 'Smith', 29, 1.85, 'British'
We created a new tuple with five elements. Three of them are strings (
'British'), one is an integer (
29), and one is a float (
1.85). Python knows that
user_data is a tuple because we used commas to separate the elements. We can also add optional parentheses around the values:
user_data = ('John', 'Smith', 29, 1.85, 'British')
Although the parentheses are optional, it's a good practice to use them around tuples.