Help with this code

Joaquin Alzola Joaquin.Alzola at lebara.com
Mon Jan 9 13:14:45 EST 2017


>> elements. For example, if we have a list_a=["a","b","c","d"] and
>> list_b=["a","b"] I want to obtain a new list_c containing elements that
>> match between these lists (a and b here),

>Perhaps this might work:

>>>> list(set(list_a).intersection(set(list_b)))
>['a', 'b']

>>> list_a={"a","b","c","d"}
>>> list_b={"a","b"}
> sorted(list_a & list_b)
['a', 'b']

------

This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.


More information about the Python-list mailing list