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 moreArray 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 ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraConditional StatementsWhile LoopsFor LoopsArrays and Lists

Longest path: 76 steps · 325 total prerequisite topics

Prerequisites (4)

Leads To (21)