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))
πŸ’¬ Discuss
βœ… Correct 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].

Explanation by: Mr. Dubey
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].

πŸ’¬ Discussion

πŸ“Š Question Analytics

πŸ‘οΈ
547
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
92%
Success Rate