Python 3 - Tuple tuple() Method


Advertisements

Description

The tuple() method converts a list of items into 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/python3

list1 = ['maths', 'che', 'phy', 'bio']
tuple1 = tuple(list1)
print ("tuple elements : ", tuple1)

Result

When we run above program, it produces the following result −

tuple elements :  ('maths', 'che', 'phy', 'bio')
python_tuples.htm
Advertisements