← back to unit
Medium
# stacks medium
Pop Until You Find It
Your library card is SOMEWHERE in the paper pile — keep lifting papers until you pull it out. 🗂️
You get the pile bottom to top, and the target (guaranteed inside). Pop until you've popped the target itself, and print how many things you popped in total.
Example:
Input: pile = ["bill", "card", "homework", "doodle"], target = "card"
Output: 3
Popping from the top removes doodle, then homework, then card itself — 3 pops total.
💡 need a hint?
stk-pop-until-found.py🔒 given lines are locked — write your code in between
loading...