I have a list of coordinates, and I need to split them in half based on their x value. Something like this:
l = [(0, 0), (1, 0), (2, 0), (3, 0), (0, 1), (1, 1), (2, 1), (3, 1)]
left = []
right = []
for i in l:
if i[0] < 2:
left.append(i)
else:
right.append(i)
print(left)
print(right)
output:
[(0, 0), (1, 0), (0, 1), (1, 1)]
[(2, 0), (3, 0), (2, 1), (3, 1)]
Is there a faster way to do this?