List Flashcards
1
Q
How do you create a list in Python?
A
my_list = [1, 2, 3]
2
Q
How do you add an item to the end of a list?
A
my_list.append(item)
3
Q
How do you remove the last item from a list?
A
my_list.pop()
4
Q
How do you insert an item at a specific position?
A
my_list.insert(index, item)
5
Q
How do you remove an item by value?
A
my_list.remove(item)
6
Q
How do you access the first item in a list?
A
my_list[0]