3.07
Completed
String Indexing String Indexing

Learn how to grab characters from Python strings using positive and negative indexes.

String Indexing

Sounds useful?

Jump into the interactive version.

No setup. No account. Just Python.

Interactive Python lesson

String Indexing in Python

This Block teaches you how to point at one specific character inside a Python string. You will start with simple examples like word[0], learn why Python starts counting from zero, and see how positive and negative indexes work in real code.

You will also learn the small but important traps: why word[len(word)] goes too far, what IndexError means, why empty strings have no valid indexes, and why spaces count as characters too.

What you will learn:

  • Get one character from a string using square brackets
  • Understand zero-based indexing with examples like word[0]
  • Use negative indexes to read from the end, including word[-1]
  • Find the last positive index with len(word) - 1
  • Avoid common off-by-one mistakes and IndexError
  • Remember that spaces are characters, and indexing does not change the original string

By the end, you will be able to confidently pick the first, last, or any specific character from a string without guessing where Python is looking.

> Start now 162 cards · about 9 min

Ready to practice this in the browser?

> Play now