Find non-common elements in lists

后端 未结 6 2197
离开以前
离开以前 2020-11-30 06:34

I\'m trying to write a piece of code that can automatically factor an expression. For example, if I have two lists [1,2,3,4] and [2,3,5], the code should be able to find th

6条回答
  •  长情又很酷
    2020-11-30 07:20

    You can use symmetric_difference command

    x = {1,2,3} y = {2,3,4}

    z = set.difference(x,y)

    Output will be : z = {1,4}

提交回复
热议问题