Python Lists and Dictionaries

Go Gocourse AI Updated 16 Aug 2026
1 min read ·Lesson 6 of 6
In this post

The two data structures most Python programs are built out of.

The two data structures most Python programs are built out of.

Lists keep order

A list is an ordered, changeable sequence. Slicing reads a section without copying the thinking into a loop.

langs = ["Python", "Go", "Rust"]
langs.append("C")
print(langs[0], langs[-1], langs[1:3])

Output:

Python C ['Go', 'Rust']

Dictionaries keep pairs

A dictionary maps keys to values and looks either up in constant time. .get() gives a default instead of raising.

stock = {"python": 12, "go": 3}
stock["rust"] = 7
print(stock["python"], stock.get("perl", 0))
for name, n in stock.items():
    print(name, n)

Output:

12 0
python 12
go 3
rust 7

Next

Carry on to the next tutorial in the rail — it picks up where this one leaves off.

PythonLists and Dictionaries

0 Comments

Reviewed before they appear

No comments yet.

Python
On this page
On this page
Python 6 posts
See all
Topics
PythonLists and Dictionaries