Level 4

Search the List

Level 4 · Chapter 9

What this lesson follows

CSTA K–12 Computer Science Standards (2017)

Algorithms & Programming · Grades 6–8

Name variables well and work with their values.

Code 2-AP-11Read the official text

Common Core State Standards for Mathematics

Number & Operations in Base Ten · Grade 5

See that each place is ten times the one to its right.

Code 5.NBT.A.1Read the official text

The short lines are our own words. We matched this lesson to these standards ourselves; the standards' owners have not reviewed or endorsed this course.

Common Core State Standards © 2010 National Governors Association Center for Best Practices and Council of Chief State School Officers. All rights reserved.

Today you will find items in a list and check if a value exists.

1👋 Warm-Up

For teachers · goals · guide
Lesson Outcomes · for teachersCSTA 2
✦ CSTA 2-AP-11 · ISTE 1.5.c · Standards
🎯 I canfind items in a list and check if a value exists
🧩 New blocks2 blocks
📝 New words5 words
⏱ Lesson time~35 min
Teacher Guide

📋 Before class

⚠️ Common misconceptions

  • Students think 'item # of' always returns a number — it returns 0 when the value is not in the list.
  • Students may use contains when they need the position. Both check existence, but only 'item # of' gives the index.

🎯 Differentiation

🐢 Struggling: Trace one search by hand on paper: write each list item, circle the match, write its index.

🚀 Advanced: Challenge students to handle a name that appears twice in the list — what index does 'item # of' return?

💡 During the lesson

  • Warm-UpAsk: "If I have a list of 100 names and I want to find 'Maria,' do I read every name one by one, or is there a smarter way?" In this chapter students use built-in list blocks. At L5 they will write their own search loop.
  • Try ItPlace both blocks on the board next to each other. Ask: "Which block would you use just to check yes/no? Which block would you use to find the exact location?" Students often want to use only one — show that both together give full information. item # of takes a value and gives a position; item (N) of does the opposite.
    Picking Zara in the second experiment exposes the 0-as-sentinel pattern. Students see that item # of returns 0 for missing names — a key idea before they learn to write their own search loops at L5.
  • PlanAsk students to draw this flowchart by hand before opening Scratch. The IF/ELSE branch with two outcomes is the key pattern to internalize. Do the first box together, then pick and watch both pictures.
  • BuildStudents who use item # of without contains may not handle the "not found" (0) case. Both approaches work — but using contains first is cleaner code. Discuss why.