Lesson 13 of 55 · Python
Data Structures – Lists
Duration: 20 minutes
Lesson 13 of 55 · Python
Duration: 20 minutes
python\ncolors = ['red', 'green', 'blue']\ncolors.append('yellow') # add to the end\nprint(colors[1]) # green\nprint(colors[-1]) # yellow (last item)\ncolors.remove('red') # delete first occurrence of 'red'\nprint(colors) # ['green', 'blue', 'yellow']\n\n\nBecause lists are mutable, you can change, add, or remove elements at any time.\n