David Hláčik wrote: > Hello , > following scenario > > list_current = [ "welcome", "search", "done", "result"] > list_ldap = [ "welcome", "hello"] > > result: > > list_toadd = [ "hello"] > > by words said , i want to check if list item from list_ldap exists in > list_current if not i want to add it to list_toadd.
Steven's example works but it won't scale for large lists. Sets are much faster if you don't require an ordered result. >>> list_current = [ "welcome", "search", "done", "result"] >>> list_ldap = [ "welcome", "hello"] >>> diff = set(list_ldap).difference(set(list_current)) >>> diff set(['hello']) >>> list_toadd = list(diff) >>> list_toadd ['hello'] Christian -- http://mail.python.org/mailman/listinfo/python-list