fork download
  1. a1=[1,3,-9,6,0]# Исходный массив
  2. a2=[]# Новая еба
  3. for i in range(len(a1)):
  4. if a1[i] < 0:
  5. a2.append(-a1[i])
  6. else:
  7. a2.append(a1[i])
  8. # Лучше:
  9. # for v in a1:
  10. # if v < 0: v = -v
  11. # a2.append(v)
  12. print(a2)
Success #stdin #stdout 0.02s 44680KB
stdin
Standard input is empty
stdout
[1, 3, 9, 6, 0]