The statement says:
Write a nonrecursive (negative) function which given a list of integers (possibly disordered) function returns the same list with negative numbers to positive head and back (regardless of the order between them). This algorithm can be solved in the form requested a similar strategy (though a bit more simple) partition in quicksort.
I put this code:
def negatius(a):
fin = len(a) - 1
i = 0
b = [i]
for i in range(len(a)):
if a[i] < 0:
b[fin] = a[i]
i += 1
else:
b[fin] = a[i]
fin += 1
print "La llista és",b[fin]
a=[1,-2,3,-4,-3,5,6]
negatius(a)
And appears an error: local variable 'i' referenced before assignment. I dont understand this