3 of 6
You're running through an obstacle course. The path has items you can collect and spikes you must dodge. Loop through the path and use continue to skip any "spike" items. Collect everything else and count how many items you picked up.
Use this path:
path = ["coin", "spike", "coin", "coin", "spike", "gem", "spike", "coin"]
Expected output:
Collected: coin
Skipped: spike
Collected: coin
Collected: coin
Skipped: spike
Collected: gem
Skipped: spike
Collected: coin
Total items collected: 5
for loop to go through the pathcontinue to skip "spike" items (but still print "Skipped" before continuing)You need to print "Skipped: spike" before calling continue, because continue skips everything after it:
if item == "spike": print(f"Skipped: {item}") continue
Create a variable like collected = 0 before the loop. After the spike check (which uses continue), increment it by 1 for each non-spike item.
The order inside the loop should be:
continue✅ Standard library: heapq, collections, itertools, math, random, functools, datetime, bisect
✅ Functions, classes, recursion, print()
❌ No file system, subprocess, OS access, or network requests
❌ No pip install (all supported modules are pre-loaded)
⏱️ 5 second execution time limit