PYTHON / COMPLETE THE SAFE-SEARCH CHALLENGE · STEP 1 OF 4
Complete the safe-search challenge
Checking your account…
GUIDED PRACTICE
Complete the safe-search challenge
Follow the current step and use Run & check this step. Your code carries forward.
Your code stays in one editor through every step. Word wrap is enabled.
Step 1 of 4
Keep both search lists
Indexes refer to these exact source orders.
Your task
Make the next small change, keeping the working code from the previous step.
To pass this step:
- Add
movies = ["Orbit", "Spark", "Loop", "Pixel", "Byte"]. - Add
colors = ["red", "blue", "green", "yellow", "purple", "orange"]. - Keep the earlier working code.
Press the play button labeled Run & check this step below the editor to run your code and see your check results.
Your editor is opening.
Each step builds on the last. Finish the current step before opening the next one; your code stays with you.
This is one possible solution. Compare it with your own code; opening it does not replace your work or complete a step.
# Build your program one step at a time.
movies = ["Orbit", "Spark", "Loop", "Pixel", "Byte"]
colors = ["red", "blue", "green", "yellow", "purple", "orange"]# Build your program one step at a time.
movies = ["Orbit", "Spark", "Loop", "Pixel", "Byte"]
colors = ["red", "blue", "green", "yellow", "purple", "orange"]
movie_position = movies.index("Pixel")
print(movie_position)# Build your program one step at a time.
movies = ["Orbit", "Spark", "Loop", "Pixel", "Byte"]
colors = ["red", "blue", "green", "yellow", "purple", "orange"]
movie_position = movies.index("Pixel")
print(movie_position)
if "purple" in colors:
purple_position = colors.index("purple")
purple_message = str(purple_position)
else:
purple_position = -1
purple_message = "purple not found"
print(purple_message)# Build your program one step at a time.
movies = ["Orbit", "Spark", "Loop", "Pixel", "Byte"]
colors = ["red", "blue", "green", "yellow", "purple", "orange"]
movie_position = movies.index("Pixel")
print(movie_position)
if "purple" in colors:
purple_position = colors.index("purple")
purple_message = str(purple_position)
else:
purple_position = -1
purple_message = "purple not found"
print(purple_message)
try:
teal_message = str(colors.index("teal"))
except ValueError:
teal_message = "teal not found"
print(teal_message)Code and completed steps save in this browser when signed out. Sign in to save across devices.
Choose the copy to continue. Your account work will only be replaced if you choose this device.
Ready to checkRun the checks to see your results here.