<br><br><div class="gmail_quote">On Wed, Sep 1, 2010 at 12:27 AM, Alban Nona <span dir="ltr"><<a href="mailto:python.koda@gmail.com">python.koda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hi all,<br><br>Im stuck on this problem:<br>I have a function which return me a list of string (basically the result looks like: ["FN067_098_MEN", FN067_098_JIN", FN067_098_BG"]<br>In other hand, I have another list full of that kind of entries:<br>



["FN067_098_MEN_Hair_PUZ_v001.0001.exr","FN067_098_JIN_Hair_SPC_v001.0001.exr","FN067_098_MEN_Jin_MVE_v001.0001.exr","FR043_010_GEN_NRM_v001.0001.exr"]<br><br>I would like to do something like this:<br>



<br>myFirstList =  ["FN067_098_MEN", FN067_098_JIN", FN067_098_BG"]<br>mySecondList = ["FN067_098_MEN_Hair_PUZ_v001.0001.exr","FN067_098_JIN_Hair_SPC_v001.0001.exr","FN067_098_MEN_Jin_MVE_v001.0001.exr","FR043_010_GEN_NRM_v001.0001.exr"]<br>



<br>for n in myFirstList:<br>    if n in mySecondList:<br>        mySecondList.remove(n)<br><br>In fact, what I want to do it to remove entries with the secondlist which content the entries of the first one. But it seems to not work like this.<br>


Someone can help me please ? did I miss something ?<br></blockquote><div><br></div><div>You can try this if you don't care about the order.</div><div><br></div><div>>>> myFirstList = ["FN067_098_MEN", "FN067_098_JIN", "FN067_098_BG"]</div>

<div>>>> mySecondList = ["FN067_098_MEN_Hair_PUZ_v001.0001.exr","FN067_098_JIN_Hair_SPC_v001.0001.exr","FN067_098_MEN_Jin_MVE_v001.0001.exr","FR043_010_GEN_NRM_v001.0001.exr"]</div>

<div>>>> list(set(mySecondList).difference(myFirstList))</div><div>['FN067_098_MEN_Jin_MVE_v001.0001.exr', 'FN067_098_MEN_Hair_PUZ_v001.0001.exr', 'FR043_010_GEN_NRM_v001.0001.exr', 'FN067_098_JIN_Hair_SPC_v001.0001.exr']</div>

<div><br></div><div>Another example to make this clear.</div><div>>>> a = range(10)</div><div>>>> b = range(5,15)</div><div>>>> a</div><div>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]</div><div>>>> b</div>

<div>[5, 6, 7, 8, 9, 10, 11, 12, 13, 14]</div><div>>>> list(set(b).difference(a))</div><div>[10, 11, 12, 13, 14]</div><div> </div><div><br></div></div>-- <br>~l0nwlf<br>