LearnFrenzy
Sign in Take a free test

List Comprehensions · List Comprehensions MCQ · Question 1

What does a list comprehension produce? Answer, explanation & discussion

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

What does [x * 2 for x in (1, 2, 3)] produce?

  • A The tuple (2, 4, 6)
  • B A generator
  • C The list [1, 2, 3, 1, 2, 3]
  • D The list [2, 4, 6] Correct
Correct Answer: Option D

Square brackets always build a list, whatever the input iterable is.

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