A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Arrays and Lists

College Depth 75 in the knowledge graph ☐ I know this ☆ Set as goal
671topics build on this
325prerequisites beneath it
See this on the map →
For LoopsMemory, Data Storage, and Variables+2 more→→Array Data Structure: Representation and OperationsArray Indexing and Bounds+19 more
arrays lists sequences indexing mutable collections

Core Idea

A list (or array) is an ordered, indexed collection of values that can be traversed, modified, and grown or shrunk. Elements are accessed by zero-based index; negative indices count from the end. Unlike strings, lists are mutable — elements can be added, removed, or changed in place. Lists are the foundational data structure for representing sequences of related items and are traversed naturally with for loops.

How It's Best Learned

Build, modify, and traverse lists by hand and in code. Implement accumulation patterns: start with an empty list, append items inside a loop, then process the result. Compare list access patterns to string slicing.

Common Misconceptions

Explainer

You already know how to store a single value in a variable and how to repeat operations with a for loop. A list is the natural next step: instead of creating five separate variables (`score1`, `score2`, ...), you create one variable that holds an ordered sequence of values. This makes it possible to process collections of unknown or variable size using the same loop code.

Every element in a list has a position called its index, and indexing starts at zero. The first element is at index 0, the second at index 1, and so on. Python (and most languages) also support negative indices that count from the end: index -1 is the last element, -2 is second-to-last. This gives you two symmetric ways to address any position, which is handy when you care about the end of a list but do not know its length in advance.

Lists are *mutable*, which distinguishes them from strings. You can change any element in place (`a[0] = 99`), append new elements (`a.append(5)`), or remove elements — all without creating a new list. This mutability is powerful, but it introduces a subtlety that surprises nearly every new programmer: when you write `b = a`, you are *not* copying the list. You are giving a second name to the same list object. Changes made through `b` are immediately visible through `a`. To get a true independent copy, use `b = a[:]` or `b = list(a)`.

The most important pattern to learn is accumulation: start with an empty list, run a loop, and append each computed value inside the loop. This pattern is how you transform one collection into another — compute the squares of a range, filter out even numbers, or extract every other element. Once you are comfortable writing this as an explicit loop, you will recognize the same structure inside list comprehensions, `map()`, and other higher-level tools.

Finally, unlike arrays in statically typed languages such as Java or C, Python lists can hold values of different types in the same list — integers, strings, and even other lists can coexist. In practice, mixing types in a single list often indicates a design problem, but the language will not stop you. When you do want the performance and type guarantees of a homogeneous fixed-type array, Python's `numpy` arrays are the right tool for that job.

Practice Questions 3 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Addition Within 10 → Number Bonds to 10 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Comparing and Ordering Integers → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Conditional Statements → While Loops → For Loops → Arrays and Lists

Longest path: 76 steps · 325 total prerequisite topics

Prerequisites (4)

Leads To (21)