Examveda

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)]

D. [(2, 3)]

Answer: Option C

Solution (By Examveda Team)

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)].

This Question Belongs to Python Program >> Python Built In Functions

Join The Discussion

Related Questions on Python Built In Functions