![]() |
VOOZH | about |
Like an empty list, we can create an empty tuple in Python. Empty tuples can work as a placeholder and are more memory efficient compared to empty lists because tuples are immutable.
Simplest way to create an empty tuple is by using ( ).
() <class 'tuple'> 0
tuple() ConstructorWe can also use tuple() constructor to create empty tuple. This method is used when tuple is created dynamically.
() <class 'tuple'> 0
We can verify is tuple is empty by checking length. Another method is to compare given tuple with an empty tuple.
The tuple is empty. The tuple is empty.
No, you cannot add items to an empty tuple (or any tuple) in Python directly because tuples are immutable. Once a tuple is created, its items cannot be changed, added, or removed.
Though, you can create a new tuple with additional elements.
(1, 2, 3)