Python Tuple tuple() Method


Advertisements


Description

The method tuple() compares elements of two tuples.

Syntax

Following is the syntax for tuple() method −

tuple( seq )

Parameters

  • seq -- This is a tuple to be converted into tuple.

Return Value

This method returns the tuple.

Example

The following example shows the usage of tuple() method.

#!/usr/bin/python

aList = (123, 'xyz', 'zara', 'abc');
aTuple = tuple(aList)

print "Tuple elements : ", aTuple

When we run above program, it produces following result −

Tuple elements :  (123, 'xyz', 'zara', 'abc')

python_tuples.htm

Advertisements