Vidyalelo
Python · Q39

Python Built

Programming · Python · question 39

Q39

What will be the output of the following Python function? list(enumerate([2, 3]))

A.
Error
B.
[(1, 2), (2, 3)]
C.
[(0, 2), (1, 3)]
Answer
D.
[(2, 3)]

Answer: Option C

Solution

Answer: Option C
Solution:
The correct answer is Option C: [(0, 2), (1, 3)].
The enumerate() function in Python is used to add a counter to an iterable and return it as an enumerate object. When the enumerate object is converted to a list using the list() function, it returns a list of tuples where each tuple contains the index and the corresponding element of the original iterable. In this case, the input list is [2,3][2,3], and its elements are indexed starting from 0. Therefore, the output will be [(0,2),(1,3)][(0,2),(1,3)].