Chapter 9 - Python Quest
Stacks
Push, pop, undo, browser history, matching pairs, and tiny calculators.
XP
0Level 1Stars
0/15quest starsCombo
0clean runsRank
Seed0/160 Python scoreStacks
100 XPSnack Stack Top
The snack helper stacks treats on a tray. New snacks go on top, and TAKE removes the snack from the top of the tray.
Write snack_stack_top(moves) so it follows each move and returns the snack on top at the end, or empty if the stack has no snacks.
Sample checks
snack_stack_top(["apple","cookie","TAKE","juice"])returns"juice"Explanation: apple goes down, cookie goes on top, TAKE removes cookie, then juice becomes the top
snack_stack_top(["book","TAKE"])returns"empty"Explanation: book is added, then TAKE removes it, so nothing is left
Hint
Hints are ready when you want one.
Lesson reference
Review: Push and pop
Your Python
snack_stack_top
Loading editor
Judge
Ready
Run your code when it feels ready.
