Python – Creates Tuple – tuple() Function with Examples

tuple() function is used to find or create a tuple in Python for the given input.

tuple() function is a part of Python Built-in Functions.

In Python programming, a tuple is similar to a list. The difference between them is that we cannot change the elements of a tuple once it is assigned whereas, in a list, elements can be changed.

Creating a tuple is as simple as putting different comma-separated values. Optionally you can put these comma-separated values between parentheses also.

Syntax of tuple() Function

The syntax of tuple() function in Python is:

Parameters of tuple() Function in Python

x – Where x is any valid . This parameter is required.

 

Compatibility

tuple() function is available and compatible with both Python 2.x and 3.x.

 

Return Value of tuple() Function in Python

tuple() function returns create a tuple in Python for the given input.

 

Python tuple() Function Example 1

Python tuple() Function Example 2

To write a tuple containing a single value you have to include a comma, even though there is only one value.