list

list(iterable)

Creates a list.

Parameters

The list() function accepts one argument:

  • iterable (optional) — an object that can be a sequence (string, tuple) or a collection (set, dictionary) or any iterator object.

Return Value

The list() function returns a list.

  • If no parameter is passed, it returns an empty list.
  • If iterable is passed, it creates a list consisting of the elements of iterable.

Examples

# Empty list
print(list())

# String of vowels
vowel_string = 'aeiou'
print(list(vowel_string))

# Tuple of vowels
vowel_tuple = ('a', 'e', 'i', 'o', 'u')
print(list(vowel_tuple))

# List of vowels
vowel_list = ['a', 'e', 'i', 'o', 'u']
print(list(vowel_list))

# Result:

[]
['a', 'e', 'i', 'o', 'u']
['a', 'e', 'i', 'o', 'u']
['a', 'e', 'i', 'o', 'u']