{"id":18187,"date":"2021-08-26T10:42:21","date_gmt":"2021-08-26T05:12:21","guid":{"rendered":"https:\/\/python-programs.com\/?p=18187"},"modified":"2021-11-22T18:37:13","modified_gmt":"2021-11-22T13:07:13","slug":"python-program-to-move-all-negative-elements-to-end-in-order-with-extra-space-allowed","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-move-all-negative-elements-to-end-in-order-with-extra-space-allowed\/","title":{"rendered":"Python Program to Move all Negative Elements to End in Order with Extra Space Allowed"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Split the Array\/List and add the First Part to the End<\/a>
\nGiven a list that contains the negative and positive elements the task is to move all the negative elements to the end of the list.<\/p>\n

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

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

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

Given List =[1, 9, -3, 6, 8, 11, 35, -5, -7, 10, -1, -2, -3]<\/pre>\n

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

The given list after moving negative elements to the end is [1, 9, 6, 8, 11, 35, 10, -3, -5, -7, -1, -2, -3]<\/pre>\n

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

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

Given List = [-7 11 56 -3 -8 12 17 -25 -8 -11 -6 9 10]<\/pre>\n

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

The given list after moving negative elements to the end is [11, 56, 12, 17, 9, 10, -7, -3, -8, -25, -8, -11, -6]<\/pre>\n

Program to Move all Negative Elements to End in Order with Extra Space Allowed in Python<\/h2>\n

There are several ways to move all the negative elements to the end of the list some of them are:<\/p>\n