阅读背景:

如何返回包含没有重复项的公共元素的列表

来源:互联网 
def common_elements(list1, list2):
    """
    Return a list containing the elements which are in both list1 and list2

    >>> common_elements([1,2,3,4,5,6], [3,5,7,9])
    [3, 5]
    >>> common_elements(["this","this","n","that"],["this","not","that","that"])
    ['this', 'that']
    """

    result = []
    for element in list1:
        if element in list2:
            result.append(element)
    return result
def common_elements(list1, list2):
    """
    



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: