03.02 · Find and sort items / Practice · 8 min
Find a movie, purple and a missing teal
The movie and purple have positions. Missing teal needs a clear fallback, not a crash.
Activity 2 of 4 in Find and sort items
Python 3: Lists / 03.02
Finding items challenge
Not started
Complete the three original search challenges with present and absent color paths.
Your lesson progress
Empty: not started. Yellow: in progress. Green: complete. Marking the whole activity complete does not replace your test results. These circles save in this browser for this pilot.

ORIGINAL WALKTHROUGH · 08:05
Watch with Rob.
Pause whenever you want to try a change. You can return to the lesson at any time.
You are signed in, but video access needs attention. Check your account access. Your saved work is kept.
Video walkthroughs are included with an active Code Zone membership. The written lesson and practice are free.
Open video & code editor (opens in a new tab)Your task: three searches
Keep the five supplied movie titles. Assign the position of "Pixel" to movie_position using index, then print movie_position.
Keep the six supplied colors. Use an if membership check for "purple". Assign its numeric position to purple_position and its printable text to purple_message. If missing, use -1 as your own marker and "purple not found" as the message. Print purple_message.
Use try and except ValueError when searching for "teal". Store the found position as text in teal_message, or "teal not found" if missing. Print teal_message. The checks expect 3, 4 and teal not found on separate lines for the supplied inputs.
A marker you choose is not what index returns
Our -1 marker only belongs to the missing-purple branch you write. index itself still raises ValueError if called with a missing value. The supplied data includes purple and excludes teal, so both techniques have a clear role.
Checks compare output and named results for these fixed inputs. They do not prove that your source uses the requested if and try statements. After passing, replace purple with pink, then add teal in another experiment. Predict each branch; restore the original inputs before checking again.
Review the source after trying it
The original 8:05 walkthrough and Solution Set remain in Skool. Use its separate code-along workspace if you want to follow the recording without replacing this challenge draft.
Build it one step at a time
Prefer learning by typing? Work through short instructions, run the Python code and check each change before continuing. Your guided project saves separately from the challenge below.
The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.
Start mini-lesson(opens in a new tab)4 steps · Saved work · Instant feedback
YOUR TURN
Handle each search outcome
Find Pixel; guard purple with membership; handle missing teal with except ValueError. Preserve both input lists and print the three requested results.
3 4 teal not found
Keep the starting inputs. Print these lines in this order, without extra output.
- Keep the requested movie position
- Keep the requested purple position
- Keep the requested purple message
- Keep the requested teal message
- Keep the requested movies
- Keep the requested colors
- Output 1 matches the requested result
- Output 2 matches the requested result
- Output 3 matches the requested result
Edit Python, then run it. Check challenge checks your output and the listed Python requirements. Your code saves on this browser after a short pause. Sign in and choose Save account draft to keep it across devices. Word wrap is enabled.
Ready to checkRun the checks to see your results here.
Your check results
Need a nudge?
Search the list by value
movies.index("Pixel") returns a number. Keep the actual movie list and search value rather than hardcoding that number.
Give missing colors a deliberate path
Check "purple" in colors before index. Catch ValueError around the teal index call. Convert a found numeric position with str when storing the message.
One possible solution
Your code may look different and still be correct. Compare the approach with your own.
The found positions are zero-based. A specific missing-value handler lets the final print statements run even when teal has no index.
Walk through the fix.
Choose Next to inspect one change at a time. Highlighted lines show what to notice. Your editor stays unchanged unless you choose to load a step.
Step 1 of 2
Keep the starting collection
Read the actual values and their positions before calculating an answer.
movies = ["Orbit", "Spark", "Loop", "Pixel", "Byte"]Expected output for this step
(No output)
Trace the operation and its result
The found positions are zero-based. A specific missing-value handler lets the final print statements run even when teal has no index.
movies = ["Orbit", "Spark", "Loop", "Pixel", "Byte"]
colors = ["red", "blue", "green", "yellow", "purple", "orange"]
movie_position = movies.index("Pixel")
if "purple" in colors:
purple_position = colors.index("purple")
purple_message = str(purple_position)
else:
purple_position = -1
purple_message = "purple not found"
try:
teal_message = str(colors.index("teal"))
except ValueError:
teal_message = "teal not found"
print(movie_position)
print(purple_message)
print(teal_message)Expected output for this step
3 4 teal not found
See the complete solution
movies = ["Orbit", "Spark", "Loop", "Pixel", "Byte"]
colors = ["red", "blue", "green", "yellow", "purple", "orange"]
movie_position = movies.index("Pixel")
if "purple" in colors:
purple_position = colors.index("purple")
purple_message = str(purple_position)
else:
purple_position = -1
purple_message = "purple not found"
try:
teal_message = str(colors.index("teal"))
except ValueError:
teal_message = "teal not found"
print(movie_position)
print(purple_message)
print(teal_message)Ready to try it?
Practice in your browser and see your results.
Progress details
Have a question?
Ask the Code Zone community.
Ask a question in The Code Zone (opens in a new tab)