Module 4

Zero-based indexing explained

Why Python starts at zero.

Why zero?

Python starts counting at zero. This feels strange at first, but it is common in programming. The index is the offset from the start: the first character is 0 positions away from the start.

1A
2T
3G
4C
Each box holds one character. len() counts them.

Think of it like a ruler. The first mark is at position 0. The second mark is at position 1. The index tells you how far to move from the beginning.

In the string "ATGC", what character is at index 2?