Google News
logo
Python Program to Create a Tuple
To create a tuple in Python, you can use the parenthesis `()` or the `tuple()` constructor. Here are examples of both :

Using parenthesis :

Program :
# Create a tuple using parenthesis
my_tuple = (1, 2, 3, 4, 5)
print(my_tuple)
Output :
(1, 2, 3, 4, 5)


Using the `tuple()` constructor :

Program :
# Create a tuple using the tuple() constructor
my_tuple = tuple([1, 2, 3, 4, 5])
print(my_tuple)
Output :
(1, 2, 3, 4, 5)
In both cases, we created a tuple with the elements `1`, `2`, `3`, `4`, and `5`. Tuples are immutable, which means that once they are created, their elements cannot be modified.