List Flashcards

1
Q

How do you create a list in Python?

A

my_list = [1, 2, 3]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you add an item to the end of a list?

A

my_list.append(item)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you remove the last item from a list?

A

my_list.pop()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you insert an item at a specific position?

A

my_list.insert(index, item)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you remove an item by value?

A

my_list.remove(item)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you access the first item in a list?

A

my_list[0]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly