Ben Bush wrote: > I have a lis: > [[1,3],[3,4],[5,6],[8,9],[14,0],[15,8]] > I want a code to test when the difference between the first element in > the list of list is equal to or larger than 6, then move the previous > lists to the end of the list. that is: > [[14,0],[15,8],[1,3],[3,4],[5,6],[8,9]]
have you tried doing this yourself? how far did you get? can you post the code so we can help you figure out what you need to fix? is this a homework assignment? here's a oneliner: L = [x for x in L if x[0]-x[1] >= 6] + [x for x in L if x[0]-x[1] < 6] depending on how you define "difference", you may need to replace x[0]-x[1] with abs(x[0]-x[1]) </F> -- http://mail.python.org/mailman/listinfo/python-list