Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python List list() method

Python List list() method

Python Lists Python Lists


Description

The list() method converts a tuple into a list.

**Note:** Tuples are very similar to lists; the difference is that tuple element values cannot be modified. Tuples are placed in parentheses, while lists are placed in square brackets.

Syntax

list() method syntax:



list( tup )

Parameters

Return Value

Returns a list.

Example

The following example shows how to use the list() function:

#!/usr/bin/python

-- coding: UTF-8 --

aTuple

=

(

123

,

'

runoob

'

,

'

google

'

,

'

abc

'

)

;

aList

=

list

(

aTuple

)

print

(

"

List elements:

"

)

print

(

aList

)

The output of the above example is:



List element :

[123, 'runoob', 'google', 'abc']

Python Lists Python Lists