Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def Rfind(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)-1
- if start>=len(s) and stop >=len(s):
- return -1
- if start==stop:
- return -1
- lensub = len(sub_string)
- if(stop-start)+1>=lensub:
- if lensub == 1:
- for i in range(stop,start-1,-1):
- if s[i] == sub_string:
- return i
- return -1
- else:
- for i in range(stop,start-1,-1):
- if (i-lensub+1)>=start:
- if s[i-lensub+1:i+1] == sub_string:
- return i-lensub+1
- else:
- return -1
- return -1
- else:
- return -1
Add Comment
Please, Sign In to add comment