انتقل للمحتوى
Robo EgyptRobo Egypt
☰ Course contents

The list: the saying of the day

Section 8: ListsLesson 8.1 · ⏱ 8 min

A list is a variable that keeps many things in order, not just one thing.

When the app opens: sayings is a list of 4 sayings. And the button picks one at random
When the app opens: sayings is a list of 4 sayings. And the button picks one at random
We tapped “New saying”
We tapped “New saying”
  • create list with makes the list.
  • in list get random is a random item, and get # 1 is the first item.
  • length of is the number of items.
  1. Add two new sayings.
  2. Make a “joke of the day” app.

📌 Another example: a random screen colour

A list of colours, and every tap picks a colour from it.

The design
The design
The blocks
The blocks
In the lab: a colour from the list
In the lab: a colour from the list
✍️ Practise
Make the example yourself: put the parts in “🎨 Design”, then the blocks, and tap ▶ Run.
✍️ Practise here in the lessonor open the lab in a new page ↗

🎯 Challenge yourself

Easy

A random name from the list of friends.

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: one of the four names.

Medium

The next saying in order (a number that goes up with every tap).

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: the second after two taps.

Hard

Write the number of items in the list.

👀 Show the solution
The design
The design
The blocks
The blocks
In the lab
In the lab

Result: 5

Finished the lesson? Mark it so your progress counts.