Advertisement
here2share

# occurance_index.py

Apr 5th, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. # occurance_index.py
  2.  
  3. def index_occur(var,target,n,z=0):
  4.     for i in range(n): z = var.index(target,z+i)
  5.     return z
  6.  
  7. T = ('1st target is at 1', 5, '2nd target is at 3', 5, 3, -1, '3rd target is at 7', 5, 25)
  8.  
  9. print (index_occur(T,5,3))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement