Data Structures
Data Structures
4.2
4.3
4.4
2
Lists
Accessing
Elements of a
List []
3
List’s Length len
Accessing
Elements
Lists Are
Mutable
4
Some
Sequences
Are
TypeError
Immutable
5
Access a
Nonexistent IndexError
Element
List Elements
in Expressions
6
Appending to
a List TypeError
+=
7
Concatenating
Lists +
TypeError
8
Accessing List
[]
range(len(concatenated_list))
concatenated_list
9
Comparison
Operators
10
Tuples
Creating
Tuples
11
Accessing
Tuple
Elements TypeError
Adding Items +=
12
Appending
Tuples to Lists
Unpacking
Sequences
13
Swapping
Values
Accessing
Safely with enumerate
enumerate
14
Sequence
Slicing
15
Slicing with
Steps
Slicing with
Negative
Indices and
Steps
Modifying
Lists Via
Slices
16
Creating a
Dictionary {}
{}
17
Empty len
Dictionary
True
False
clear
18
Iterating
through a items
Dictionary
19
Accessing the
Value
Associated
with a Key
Adding a New
Key-Value Pair
20
Removing a
Key-Value Pair
Attempting to
Access a
Nonexistent
Key
21
Dictionary
Methods keys
and values
Converting
Dictionary to
Lists
22
Sets
ints floats
[]
Creating a Set
23
Determining a
Set’s Length
Checking
Whether a
Value Is in a
Set
Iterating
Through a Set
set Function
24
Union
Intersection
Difference
Symetric
Difference
25
Union
Augmented
Assignment
update
add
remove
26
Introduction
27
End of File
28
Writing to a
Text File
29