What's wrong with this code?
My input:
4
949 -1 3957 949
My output:
949 -1 949 949
How did that happen?
n = int(input()) m = [int(i) for i in input().split()] l = [] for i in range(n): if m[i] != -1: l.append(m[i]) l.sort() for i in range(n): if(m[i] != -1) and m[i] in l: m[i] = l[0] del l[0] for i in range(n): print(m[i], end = ' ')It's supposed to rearrange the inputs the increasing manner, except for -1's.
My input:
4
949 -1 3957 949
My output:
949 -1 949 949
How did that happen?