Examveda

What is the output of the following code:
my_list = [1, 2, 3]
print(list(reversed(my_list)))

A. [3, 2, 1]

B. [1, 2, 3]

C. ['3', '2', '1']

D. [1, 3, 2]

Answer: Option A

Solution (By Examveda Team)

The correct answer is Option A: [3, 2, 1].
The reversed() function in Python is used to reverse the elements of an iterable. When you pass the list [1, 2, 3] to the reversed() function and then convert the result to a list using list(), it returns a new list with the elements reversed, resulting in [3, 2, 1].

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

Join The Discussion

Related Questions on Python Built In Functions