On Apr 3, 12:20 pm, "bahoo" <[EMAIL PROTECTED]> wrote: > Hi, > > I have a list like ['0024', 'haha', '0024'] > and as output I want ['haha'] > > If I > myList.remove('0024') > > then only the first instance of '0024' is removed. > > It seems like regular expressions is the rescue, but I couldn't find > the right tool. > > Thanks! > bahoo
Here are a couple of ways: target = "0024" l = ["0024", "haha", "0024"] ------------------------------------ while(True): try: l.remove(target) except ValueError: break print l ------------------------------------- for index, val in enumerate(l): if val==target: del l[index] print l -- http://mail.python.org/mailman/listinfo/python-list