Python AND operator on two boolean lists - how?

前端 未结 9 2145
感动是毒
感动是毒 2020-11-28 09:36

I have two boolean lists, e.g.,

x=[True,True,False,False]
y=[True,False,True,False]

I want to AND these lists together, with the expected o

9条回答
  •  半阙折子戏
    2020-11-28 10:27

    You can use the zip function

    x=[True,True,False,False]
    y=[True,False,True,False]
    z=[a and b for a,b in zip(x,y)]
    

提交回复
热议问题