I want to find the index of the n\'th occurrence of an item in a list. e.g.,
x=[False,True,True,False,True,False,True,False,False,False,True,False,True] >
Here is another way to find the nth occurrence of x in a list itrbl:
nth
x
itrbl
def nthoccur(nth,x,itrbl): count,index = 0,0 while count < nth: if index > len(itrbl) - 1: return None elif itrbl[index] == x: count += 1 index += 1 else: index += 1 return index - 1