Mask elements of an array in vanilla Python

后端 未结 0 1604
予麋鹿
予麋鹿 2021-01-03 16:52

Is there an idiomatic way to mask elements of an array in vanilla Python 3? For example:

a = [True, False, True, False]
b = [2, 3, 5, 7]
b[a]

相关标签:
回答
  • 消灭零回复
提交回复
热议问题