I have a list like this
Use next with enumerate:
If there is not value as not zero, the None will be returned.
>>> myList = [0.0 , 0.0, 0.0, 2.0, 2.0]
>>> next((i for i, x in enumerate(myList) if x), None) # x!= 0 for strict match
3 # The first index to have value with true value which means not zero
Source From Here Question I want to kill a whole process tree. What is the best way to do this using any common scripting languages? ...