This is chapter 7, Games of Fortune, from the book Scratch 1.4: Beginner’s Guide.
In Scratch it is easy to create projects that
incorporate dynamic information using variables. However, variables
have a limitation; they store only one value at a time. Sometimes, we
want a variable to store multiple values.Welcome to lists. In Scratch, a list allows us to associate one list
(a variable) with multiple items or values in much the same way we
create a list before going to the grocery store. In this article, we will take a trip to the fortune-teller to demonstrate lists, and you’ll learn how to:
- Store and retrieve information in lists
- Add and remove items from the lists
- Keep track of items in a list by using a counter
- Identify intervals using the mod block
- Use if/else control blocks to make decisions
Fortune-teller
Most of us enjoy a good circus, carnival, or
county fair. There’s fun, food, and fortunes. Aah, yes, what would a
fair be without the fortune-teller’s tent? By the end of this article,
you’ll know everything you need to spin your fortunes and amaze your
friends with your wisdom.
Before we start the first exercise,
create a new project and add two sprites. The first sprite will be the
seeker. The second sprite will be the teller. Choose any sprites you
want. My seeker will be a clam and my teller will be a snowman. If you
want to add a background, go ahead.
Time for action – create a list of questions
In
order to have a successful fortune-telling, we need two things: a
question and an answer. Let’s start by defining some questions and
answers:
- Select the seeker from the list of sprites.
- From the Variables palette, click the Make a list button.
- In the list name dialog box, type questions and select For this sprite only.
- Click OK to create the list. Several new blocks display in the Variables palette, and an empty block titled seeker questions displays on the stage.

- Let’s think about a couple of questions we may be tempted to ask, such as the following:
- Will my hair fall out?
- How many children will I have?
- Let’s add our proposed questions to the questions list. Click the plus sign located in the bottom-left corner of the seeker questions box (on the stage) to display a text input field. Type Will my hair fall out?
- Press the plus sign again and enter the second question: How many children will I have? We now have two questions in our list.To automatically add the next item in the list, press enter.
- Let’s add a say for 2 secs block to the scripts area of the seeker sprite so that we can start the dialog.
- From the Variables palette, drag the item of questions block to the input value of the say for 2 secs block.
- Double-click on the block and the seeker asks, “Will my hair fall out?“
- Change the value on the item block to last and double-click the block again. This time the seeker asks, “How many children will I have?“

What just happened?
I’m
certain you could come up with a hundred different questions to ask a
fortune-teller. Don’t worry, you’ll get your chance to ask more
questions later.
Did you notice that the new list we created
behaved a lot like a variable? We were able to make the questions list
private; we don’t want our teller to peek at our questions, after all.
Also, the list became visible on the screen allowing us to edit the
contents.
The most notable difference is that we added more than
one item, and each item corresponds to a number. We essentially created
a numbered list.
If you work with other programming languages, then you might refer to lists as arrays.
Because the seeker’s questions were contained in a list, we used the item block to provide special instructions to the say
block in order to ask the question. The first value of the item block
was position, which defaulted to one. The second value was the name of
the list, which defaulted to questions.
In contrast, if we used a variable to store a question, we would only need to supply the name of the variable to the say block.
Purchase the book from Amazon, using my affiliate link or continue reading the rest of this scratch tutorial at scratchguide.com.

{ 1 comment… read it below or add one }
Greeting from over the world. detailed blog I will return for more.