← Back to Classes
Question 490
Pop Off The Pile
Pop Off The Pile
A Pile keeps its values in a list attribute called items, and push already adds to the end. Write the body of pop so it removes the last value from the list with .pop() and returns it. Do NOT write a main block or any top-level test code; the tests construct the class. Input: one line of whole numbers separated by spaces, which the tests push in order; the tests then print what your pop returns, followed by the list that remains.
Expected Output:
15 [4, 8]
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.