DEMO: Read the instructions below and use the code in the editor to learn about indexes.

Index is the word we use to talk about position of a value inside of a list.

Indexes start counting at 0. So the first value in a list is at index [0]. The second value in a list is at index [1].

  • Change the number of the index in the last line of code. Click Run to see the index change.

If you enter a number greater than 3, you'll get an index out of range error! Why?

To navigate the page using the TAB key, first press ESC to exit the code editor.

sprite_zero = codesters.Sprite("parrot", -185, 25) sprite_one = codesters.Sprite("snake", -60, 25) sprite_two = codesters.Sprite("monkey", 65, 25) sprite_three = codesters.Sprite("penguin", 190, 25) pets = [sprite_zero, sprite_one, sprite_two, sprite_three] selected_pet = pets[1]
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)