Python List reverse() MethodPython reverse() method reverses elements of the list. If the list is empty, it simply returns an empty list. After reversing the last index value of the list will be present at 0 index. The examples and method signature is given below. SignatureParametersNo parameter ReturnIt returns None. Let's see some examples of reverse() method to understand it's functionality. Python List reverse() Method Example 1Let's first see a simple example to reverse the list. It prints all the elements in reverse order. Output: ['e', 'l', 'p', 'p', 'a'] Python List reverse() Method Example 2It returns empty list if the list is the list is empty. See the example below. Output: [] Python List reverse() Method Example 3This example demonstrate that after reversing order of element does not change. Output: Both are equal
Next TopicPython Lists
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week