Python reversed() FunctionPython reversed() function returns the reversed iterator of the given sequence. SignatureParameterssequence: It is a sequence that needs to be reversed. ReturnIt returns the reversed iterator of the given sequence. Python reversed() Function Example 1The above example shows the working of reversed for a sequence: string, tuple, list, and range. Output: ['a', 'v', 'a', 'J'] ['a', 'v', 'a', 'J'] [11, 10, 9, 8] [5, 7, 2, 1] Explanation: In the above example, we have taken a string that consists the value "Java", and it prints the reversed string value as the output. In the second case, we have taken a tuple value that consists of the same value, and it prints the reversed tuple value as the output. In the third case, we have taken a range that consists of a range of numeric values, and it prints the reversed range values as output. In the fourth case, we have taken a list that consists of some numeric values, and it prints the reversed list value as output. Next TopicPython Built in Functions |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India