QuestenaPractice that shows what to review next
Question 72

What is the value of [count * 2 for count in [1, 2, 3, 4] if count % 2 == 0]?

  1. [2, 4]
  2. [1, 2, 3, 4]
  3. [2, 6]
  4. [4, 8]Correct answer

Explanation

The filter admits the even inputs 2 and 4, and the expression doubles each admitted value to build the result. A list comprehension creates a new list rather than modifying the input list or returning a generator object.

Continue with this test

Start practice
Question 72: What is the value of [count * 2 for count in [1, 2, 3, 4]… · Python Fundamentals · Questena