what does list do in python code example
Example 1: list in python
thislist = ["apple", "banana", "cherry"]
print(thislist[1])
Example 2: list in python
myfavouritefoods = ["Pizza", "burgers" , "chocolate"]
print(myfavouritefoods[1])
#or
print(myfavouritefoods)
Example 3: 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 4: list in python
#list is data structure
#used to store different types of data at same place
list = ['this is str', 12, 12.2, True]