Python Program to Create a Tuple

Write a Python program to create a Tuple with an example. In Python Programming language, there are two ways to create a Tuple. The first option is using the () brackets, and the other option is the tuple() function.

The following Python example creates an empty tuple using both the options.

x = ()


y = tuple()

Output of an Empty Tuple


In this example program, we are creating a tuple of items. We all know that the tuple function accepts any iterator and converts it into the tuple. So, we declared a fruits list and used the Python tuple function to convert it into a tuple.

x = (10, 20, 30, 40, 50)
print("Datatype of y      = ", type(x))

fruits = ['Kiwi', 'Banana', 'Apple', 'Orange']
y = tuple(fruits)

print("Datatype of Fruits = ", type(fruits))
print("Datatype of y      = ", type(y))
Python Program to Create a Tuple 2

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.