Python List list() method
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
- tup -- the tuple to be converted into a list.
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
'
,
'
'
,
'
abc
'
)
;
aList
=
list
(
aTuple
)
(
"
List elements:
"
)
(
aList
)
The output of the above example is:
List element :
[123, 'runoob', 'google', 'abc']
Python Lists