I have a list that I want to split by condition:
l = [1,2,3,7,8,9,4]
to
l1 = [1,2,3,4] , l2 = [7,8,9]
Based on the condition: x > 5. The code is:
l1 = []
l2 = []
for x in l:
if x > 5:
l1.append(x)
else:
l2.append(x)
Is there a more pythonic/faster way to do it?