

McqMate
Q. |
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» D. list(reversed(l)) | |
Explanation: the built-in function reversed() can be used to reverse the elements of a list. this function accepts only an iterable as an argument. to print the output in the form of a list, we use: list(reversed(l)). the output will be: [4,3,2]. |
View all MCQs in
Problem Solving and Python ProgrammingNo comments yet