Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Find(s,sub_string,start = 0, stop = None):
- #@param s: string; stringa su cui cercare
- #@param sub_string: string; stringa da cercare
- #@param start: int
- #@param stop: int
- if stop == None or stop >= len(s):
- stop = len(s)
- if start>=len(s) and stop >=len(s):
- return -1
- lensub = len(sub_string)
- if(stop-start)+1>=lensub:
- if lensub == 1:
- for i in range(start,stop):
- if s[i] == sub_string:
- return i
- return -1
- else:
- for i in range(start,stop):
- if(i+lensub)-1 > stop:
- return -1
- else:
- if s[i:lensub+i] == sub_string:
- return i
- return -1
- else:
- return -1
Add Comment
Please, Sign In to add comment