On Jun 12, 11:46 pm, "Steven Clark" <[EMAIL PROTECTED]> 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. > > > Thanks! > > > D. > > list_toadd = [i for i in list_ldap if i not in list_current] > seems to work. > > I'm sure there's a way to do it with set objects as well. > -Steven
>>> list_current = [ "welcome", "search", "done", "result"] >>> list_ldap = [ "welcome", "hello"] >>> to_add = set(list_ldap) - set(list_current) >>> to_add set(['hello']) - Paddy. -- http://mail.python.org/mailman/listinfo/python-list