python get element from list

Solutions on MaxInterview for python get element from list by the best coders in the world

showing results for - "python get element from list"
Mara
16 Aug 2017
1my_list = ["pizza", "soda", "muffins"]
2
3my_list[0] # outputs "pizza"
4my_list[-1] # outputs the last element of the list which is "muffins"
5my_list[:] # outputs the whole list
6my_list[:-1] # outputs the whole list except its last element
7
8# you can also access a string's letter like this