Programming Languages
Python
Subjective
Sep 30, 2025
What is the difference between `append()` and `extend()` methods? Show with examples.
Detailed Explanation
append() adds single element:\nlst = [1, 2]; lst.append([3, 4]); # [1, 2, [3, 4]]\n\nextend() adds multiple elements:\nlst = [1, 2]; lst.extend([3, 4]); # [1, 2, 3, 4]
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts