Easy Tutorial
❮ Python String Max Python String Min ❯

Python3 List list() Method

Python3 List


Description

The list() method is used to convert a tuple or a string into a list.

Note: Tuples and lists are very similar, but the elements of a tuple cannot be modified. Tuples are enclosed in parentheses, while lists are enclosed in square brackets.

Syntax

Syntax for the list() method:

list( seq )

Parameters

Return Value

Returns a list.

Example

The following example demonstrates the use of the list() function:

#!/usr/bin/python3

aTuple = (123, 'Google', 'tutorialpro', 'Taobao')
list1 = list(aTuple)
print("List elements : ", list1)

str = "Hello World"
list2 = list(str)
print("List elements : ", list2)

The output of the above example is as follows:

List elements :  [123, 'Google', 'tutorialpro', 'Taobao']
List elements :  ['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']

Python3 List

❮ Python String Max Python String Min ❯