Python Tuple append() Method

Advertisements


Description

The method append() appends a passed obj into the existing tuple.

Syntax

Following is the syntax for append() method:

tuple.append(obj)

Parameters

  • obj -- This is the object to be appended in the tuple.

Return Value

This method does not return any value but updates existing tuple.

Example

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

#!/usr/bin/python

aTuple = (123, 'xyz', 'zara', 'abc');
aTuple.append( 2009 );
print "Updated Tuple : ", aTuple;

When we run above program, it produces following result:

Updated Tuple :  [123, 'xyz', 'zara', 'abc', 2009]



Advertisements
Advertisements