{"id":24720,"date":"2021-11-02T09:45:44","date_gmt":"2021-11-02T04:15:44","guid":{"rendered":"https:\/\/python-programs.com\/?p=24720"},"modified":"2021-11-05T17:22:35","modified_gmt":"2021-11-05T11:52:35","slug":"python-list-reverse-method-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-list-reverse-method-with-examples\/","title":{"rendered":"Python List reverse() Method with Examples"},"content":{"rendered":"

In the previous article, we have discussed Python List remove() Method with Examples<\/a>
\nList in Python:<\/strong><\/p>\n

Lists in Python are mutable sequences. They are extremely similar to tuples, except they do not have immutability constraints. Lists are often used to store collections of homogeneous things, but there is nothing stopping you from storing collections of heterogeneous items as well.<\/p>\n

List reverse() Method in Python:<\/strong><\/p>\n

The reverse() method reverses the list’s elements.<\/p>\n

Syntax:<\/strong><\/p>\n

list.reverse()<\/pre>\n

Parameters: <\/strong>This function has no parameters.<\/p>\n

Return Value:<\/strong><\/p>\n

The reverse() method produces no output. It is used to update the existing list.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given List = ['welcome', 'to', 'Python', 'programs']<\/pre>\n

Output:<\/strong><\/p>\n

The given original list: ['welcome', 'to', 'Python', 'programs']\r\nThe given list after reversing :  ['programs', 'Python', 'to', 'welcome']<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given List = [10, 20, 30, 40, 50]<\/pre>\n

Output:<\/strong><\/p>\n

The given original list: [10, 20, 30, 40, 50]\r\nThe given list after reversing :  [50, 40, 30, 20, 10]<\/pre>\n

List reverse() Method with Examples in Python<\/h2>\n