list() function python code example

Example 1: list() python

# empty list
print(list())
#-->[]

# vowel string
vowel_string = 'aeiou'
print(list(vowel_string))
#-->['a', 'e', 'i', 'o', 'u']

# vowel tuple
vowel_tuple = ('a', 'e', 'i', 'o', 'u')
print(list(vowel_tuple))
#-->['a', 'e', 'i', 'o', 'u']

# vowel list
vowel_list = ['a', 'e', 'i', 'o', 'u']
print(list(vowel_list))
#-->['a', 'e', 'i', 'o', 'u']

Example 2: python list constructor

nuts = list("pecan nut", "walnut", "cashew nut", "macadamia nut")

forrests_favorites = list(nuts) # makes a new list with the same content