You are on page 1of 16

1

PYTHON
3

7
LIST
8

9
METHODS
10

11
In Python - a list is a data structure
used to store many items.

Items are Ordered (they exist in a


defined order), and Changeable (they
can be altered, adding, removed)

Lists also allow duplicate items.


There are many important methods


that can be used with lists...
1

.append()
4

6
Adds an element to the end of
7 your list
8

10

11
1

.insert()
4

6
Adds an element to a specified
7 position in your list
8

10

11
1

.extend()
4

6
Adds all individual elements from
7 another list (or another iterable)
8
to the end of your list

10

11
1

.index()
4

6
Returns the index (position) of
7 the first element in your list with
8
some specified value

10

11
1

.count()
4

6
Returns the number of elements
7 within your list that are equal to
8
some specified value

10

11
1

.remove()
4

6
Removes the first item in your list
7 that is equal to some specified
8
value

10

11
1

.pop()
4

6
Removes (and returns) the
7 element that exists at a specified
8
index position

10

11
1

.sort()
4

6
Sorts the elements in your list
7 (ascending order by default)
8

10

11
1

.reverse()
4

6
Reverses the order of the
7 elements in your list
8

10

11
1

.copy()
4

6
Returns a copy of your list
7

10

11
1

.clear()
4

6
Removes all elements of your list
7

10

11
Want to land an
incredible role in the
exciting, future-proof,
and lucrative field of
Data Science?
"I had over 40 interviews without an offer.
After DSI I quickly got 7 offers including one
at KPMG and my amazing new role at
Deloitte!" - Ritesh

"The best program I've been a part of, hands


down"
- Christian

"DSI is incredible - everything is taught in


such a clear and simple way, even the more
complex concepts!"
- Arianna
>> https://data-science-infinity.teachable.com

You might also like