← back to unit
Easy
# stacks easy
Top of the Pile
Peek at the top pancake WITHOUT eating it — the pile must survive your curiosity. 👀
You get the items in the order they were stacked (last one is on top). Print the top item on line one, then the whole untouched pile on line two, comma-separated bottom to top.
Example:
Input: items = ["plate", "bowl", "cup"]
Output:
cup
plate,bowl,cup
"cup" was stacked last, so it's the top (items[-1]). Peeking doesn't remove anything, so the full pile still prints as plate,bowl,cup.
💡 need a hint?
stk-top-of-pile.py🔒 given lines are locked — write your code in between
loading...