En esta página, tú vas a aprender a programar la funcionalidad para que el usuario pueda elegir el disfraz de su personaje o avatar.
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 (costumes) to report a list of the costumes for your sprite.
And you can use item of together with my (costumes) to select a costume in a specific position in the list.
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
.