Preface: Or I, a naively small white, risking his life to the company of a forced lattice interview, go to interview on the way to experience some twists and turns, the bus death not come, finally almost missed the interview time, this is not what, although the interview does not hold any hope, But the technical side was abused into slag also really hit my self-confidence, and finally the interviewer looked like a mentally retarded look (distressed himself for half a minute).
Title: Give d = [True, False, True, False, true], use list D to return the list in just one sentence [0,2,4]
The key to this problem is to get the index value of true, initially I used the index method of list with the higher order function filter to solve, but I ignored the index can only get the first true indexes (that is, 0). There is no answer to the question on the Internet, so I went to search how to get the same worthy index and be inspired, so I thought of the following three methods. If you have a different solution, please also reply in the message, we communicate together and progress together.
A Python interview question: given d = [true, False, True, False, true], use list D to return the list in just one sentence [0,2,4]