Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from string import *
- def countSubStringMatch(target,key):
- """Enter target string and search key string"""
- assert isinstance(target,str), "Target value not string"
- assert isinstance(key,str), "Key value not string"
- length=0
- index=0
- count=0
- for i in range(0,len(target)):
- index=target.find(key,index+length)
- length=len(key)
- if index!=-1:
- count+=1
- elif index==-1 and count==0:
- return -1
- else:
- return count
Advertisement
Add Comment
Please, Sign In to add comment