Common elements between two lists with no duplicates

后端 未结 5 1389
时光说笑
时光说笑 2021-01-16 05:19

Problem is this, take two lists, say for example these two:

a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
         


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 05:40

    c = []
    for items in a:
        for numbers in b:
            if items == numbers:
                if items in c:
                    None
                else:
                    c.append(items)
    print(c)
    

提交回复
热议问题