Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def searcher(word: str, text: str, num: int = 1):
- global startindex
- global size
- global rflag
- if num == 1 and text.count(word) == 1:
- startindex = text.find(word);
- size = len(word);
- rflag = "word start from " + str(startindex + 1) + " and end in " + str(size + startindex)
- elif num > 1 and text.count(word) <= num:
- startindex = 0
- for i in range(num):
- startindex = text.find(word, startindex)
- size = startindex + len(word)
- rflag = "word start from " + str(startindex + 1) + " and end in " + str(size + startindex)
- return rflag
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement