In Click Alonzo, the game switched back and forth between two different versions of the Alonzo costume in order to tell the player whether they successfully clicked Alonzo. On this page, you will allow the user of your Click Alonzo program to choose the sprite's costume.
block using different inputs to switch the sprite's costume manually a few times.switch to costume block's pulldown menu. But imagine you're giving this game to a non-programmer friend to play. You want to program the selection of a new costume inside the game, so your friend doesn't have to know anything about blocks.
When you used item of before (for example, inside who and does what) , you were accessing items of the list randomly. But you can also select a specific item by specifying its position.
The position number is called the index of the item in the list.

In this list, 1 is the index of the item "apple," 2 is the index of the item "cantaloupe," and so on.
In Snap! and on the AP exam, the index is always a whole number (1, 2, 3, 4, etc.). It is an error to use an index less than 1 or greater than the length of the list.
Lists can contain anything: letters or words, costumes, other lists, or even blocks. You can use my to report a list of the costumes for your sprite.
my block looks like
until you select "costumes" from its drop-down menu.
And you can use item of together with my to select a costume in a specific position in the list.
costumes[1]
len(costumes)
item of) have input slots that expect a list. You can tell because the input slot looks kind of like a list:
You can drag blocks into the input slot of switch to costume even though it's a drop-down menu.
to show the contents of that variable.Ask the player "Which costume number do you want?"answer.
would be written as costumes[2]or
. All three versions of this code would report/return the penguin costume (if only the AP language had costumes as a data type):




would be written as LENGTH(wordsList)or
.