Last modified: Jan 10, 2023 By Alexander Williams
2 Methods to create an empty tuple in python
Tuples are sequences used to store multiple items in a single variable. We'll learn two methods to create an empty tuple in this tutorial.
1. Create an empty tuple using the () symbol
The () symbol can be used in python to create an empty tuple.
Syntax
my_tuple = ()
Example
In the following example, we'll create an empty tuple using the () symbol.
# Tuple
my_tuple = ()
# Print "my_tuple"
print(my_tuple)
Output:
()
1. Create an empty tuple using tuple()
The tuple() built-in function can be used to create an empty tuple.
Syntax
my_tuple = tuple()
Example
Let's create an empty tuple using the tuple() built-in function.
# Tuple
my_tuple = tuple()
# Print "my_tuple"
print(my_tuple)
Output:
()
The difference between the () symbol and the tuple()
After learning two methods to create an empty tuple. Both ways work perfectly, but the tuple() built-in function is slower than the () symbol.