On Jun 14, 12:30 pm, HMS Surprise <[EMAIL PROTECTED]> wrote: > Just wondered if there was some python idiom for moving a few items > from one list to another. I often need to delete 2 or 3 items from one > list and put them in another. Delete doesn't seem to have a return > value. I don't care which items I get so now I just use a couple of > pops or a for loop for more than two. > > Thanks > > jh
>>> x = range(10) >>> y = [] >>> y.append(x.pop(4)) >>> print x, y [0, 1, 2, 3, 5, 6, 7, 8, 9] [4] >>> y.append(x.pop(7)) >>> print x, y [0, 1, 2, 3, 5, 6, 7, 9] [4, 8] HTH, George -- http://mail.python.org/mailman/listinfo/python-list