Install

Vakataka, a tap away.

Add it to your home screen for a quicker way back to your next card.

iPhone or iPad
Open in Safari, tap Share, then Add to Home Screen. Choose Open as Web App if shown, then Add.
Android
Open your browser menu and choose Install app or Add to Home screen.
Computer
Use the install icon in the address bar or your browser’s app menu. In Safari on Mac, choose File → Add to Dock.

If your browser has no install option, Vakataka still works here.

Why is the first character at position zero?

Many programming languages index sequences from zero.

An index identifies a position in a sequence. In Python, the first character of a string has index 0, the next has index 1 and so on. This convention makes the index match the number of steps from the beginning: to reach the first character, move zero steps.

You can use an index to retrieve one character, but an index outside the sequence raises an error. Keeping the length separate from the last valid index prevents a common mistake: a string with five characters has indexes 0 through 4.

A small example

For `word = "card"`, `word[0]` is `c` and `word[3]` is `d`.

Keep in mind

Indexing rules differ across languages and data structures; this example describes Python strings.

Source & attribution

Introduction to Python Programming — Strings revisited

OpenStax contributors · OpenStax, Rice University

CC BY 4.0. Rewritten as a self-contained explanation; the example and activity are Vakataka additions. No source images reproduced.

Source edition: 2024-07-30T19:17:56Z

Select the link to copy it.

Email · WhatsApp

A note to yourself

Create an account or sign in to keep private notes and saved cards across devices.