Dictionaries, Part 1

Intermediate Python

Hugo Bowne-Anderson

Data Scientist at DataCamp

List

pop = [30.55, 2.77, 39.21]

countries = ["afghanistan", "albania", "algeria"]
ind_alb = countries.index("albania")
ind_alb
1
pop[ind_alb]
2.77
  • Not convenient
  • Not intuitive
Intermediate Python

Dictionary

pop = [30.55, 2.77, 39.21]

countries = ["afghanistan", "albania", "algeria"] ...
{ }
Intermediate Python

Dictionary

pop = [30.55, 2.77, 39.21]

countries = ["afghanistan", "albania", "algeria"] ...
{"afghanistan":30.55, }
Intermediate Python

Dictionary

pop = [30.55, 2.77, 39.21]

countries = ["afghanistan", "albania", "algeria"] ...
world = {"afghanistan":30.55, "albania":2.77, "algeria":39.21}
world["albania"]
2.77
Intermediate Python

Let's practice!

Intermediate Python

Preparing Video For Download...