WAP to define a function Arrange( ) that accepts a list of integers and arrange the list in such a manner that the negative numbers are arranged from right to left at the end of the list.
For Ex : If L=[2, -5, -7, 4, 0, -3, 8, -2, 13, 22, -9], then after the program the list should contain L= [2, 4, 0, 8, 13, 22, -9, -2, -3, -7, -5]
Answers
Answered by
0
Answer:
def wap(arr):
negArr=[]
posArr=[]
for i in arr:
if i<0:
negArr.append(i)
else:
posArr.append(i)
return posArr+negArr
Explanation:
hope this helps..
A like is much appreciated ❤️
Similar questions