'how can i do list from If statement? [closed]

I am a beginner in programming and I want to improve my knowledge, I have one problem that I can not solve, so maybe someone can help if you know the solution and have time. i have this piece of code:

l=[[1,2], [3,4], [-9,5]]
for i in l:
   a=i[0]
   b=i[1]
   l1=[]
   if a>0 and b>0:
      l1.append([a,b])
   elif a<0 and b>0:
      l1.append([-a,b])
   elif a>0 and b<0:
      l1.append([a,-b])
   elif a < 0 and b < 0:
      l1.append([-a, -b])
   print(l1,end=' ')

i tried this one and i got this output:

[[1, 2]] [[3, 4]] [[9, 5]]

Maybe someone knows how to get this output?:

[[1,2], [3,4], [9,5]]



Solution 1:[1]

You can also use a tuble inside your list.

l1 = [(-5, 10), (-3, 5), (-53.7228, 3.72281), (-3, 4), (-6.32456, 6.32456)]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Miron Barykin