Python List


List function

The list() function return the elements of a list, tuple, dictionary, set or string.

Examples

Example 1

>>> x = 1, 23, 'tuple'
>>> list(x)
[1, 23, 'tuple']
>>> y = ['c', 'list', 5, 8]
>>> list(y)
['c', 'list', 5, 8]
>>> z = {10, 7, 'set', 'fv'}
>>> list(z)
[7, 10, 'fv', 'set']
>>> 

Example 2

>>> a = 'hello!'
>>> list(a)
['h', 'e', 'l', 'l', 'o', '!']
>>>