Predict List Method Output
Predict Output Easy
Question
What does this code print?
Code
nums = [1, 2, 3, 4]
nums.pop()
nums.append(5)
print(nums)
Hint
pop() removes the last element; append() adds to the end.
Explanation
pop() removes and returns the last element (4), leaving [1, 2, 3]. append(5) adds 5 to the end, giving [1, 2, 3, 5]. print outputs: [1, 2, 3, 5]
Related Resources
Related Lessons
- Lists
List methods.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.