LearnFrenzy
Sign in Take a free test

Lists · Lists MCQ · Question 1

append() versus extend() Answer, explanation & discussion

  • MCQ
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 1 Back to Exercise

After a = [1, 2] and a.append([3, 4]), what is len(a)?

  • A 3 Correct
  • B 4
  • C 2
  • D TypeError
Correct Answer: Option A

append adds its argument as a single item, so a is [1, 2, [3, 4]]. extend([3, 4]) would give length 4.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links