?
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?
Answer & Solution
Correct Answer:
Option
D
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.
Join the Discussion
Login to post a comment or share your explanation.
Login