Examveda

Suppose there is a list such that: l=[2,3,4]. If we want to print this list in reverse order, which of the following methods should be used?

A. reverse(l)

B. list(reverse[(l)])

C. reversed(l)

D. list(reversed(l))

Answer: Option D

Solution (By Examveda Team)

To print a list in reverse order in Python, you can use the reversed() function, which returns an iterator that yields items in reverse order. However, to display it as a list, you need to convert the iterator back to a list using the list() function. Therefore, list(reversed(l)) is the correct method to print the list l in reverse order.

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

Join The Discussion

Related Questions on Python Built In Functions