问题 I have an ascending list of integers e that starts from 0 and I would like to have a binary list b whose i -th element is 1 if and only if i belongs to e . For example, if e=[0,1,3,6] , then this binary list should be [1,1,0,1,0,0,1] , where the first 1 is because 0 is in e , the second 1 is because 1 is in e , the third 0 is because 2 is not in e , and so on. You can find my code for that below. My question is: is there something built-in in python for that? If not, is my approach the most