Lists
In this Lecture, we'll learn everything about Python lists: creating lists, changing list elements, removing elements, and other list operations with the help of examples.
# a list of programming languages
languages = ['Python', 'Java', 'C++', 'C#', 'JavaScript']# list of integers
numbers = [1, 2, 3, 4, 5]mixed_list = ["Apple", 12, "Banana", 45.7, False]nested_list = ["Apple", ["Banana", "Cherry"], "Durian"]my_list = ["Apple", "Banana", "Cherry"]
# first item in the list
my_list[0] # Apple
# second item in the list
my_list[1] # Banana
# third item in the list
my_list[2] # Cherry
# last item in the list
my_list[-1] # Cherry
nested_list = ["Apple", ["Banana", "Cherry"], "Durian"]
# first item in the list
nested_list[0] # Apple
# second item in the list
nested_list[1] # ["Banana", "Cherry"]
# first item in the nested list
nested_list[1][0] # Banana
# second item in the nested list
nested_list[1][1] # CherryAdd/Change List Elements
Delete List Elements
List Methods
Methods
Descriptions
List Comprehension: Elegant way to create Lists
Other List Operations in Python
Iterating Through a List
Last updated
