What will be the result of [x for x in range(5)] in Python?
-
A
[0, 1, 2, 3, 4]
Correct answer
-
B
[1, 2, 3, 4, 5]
-
C
[1, 2, 3, 4]
-
D
[0, 1, 2, 3]
Correct answer
A. [0, 1, 2, 3, 4]
14 views
Explanation
List comprehension generates a list containing numbers from 0 to 4.
Doubts & discussion
Not sure why the answer is A? Ask here and get an explanation.
Ask a doubt about this MCQ