Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- def recurse(chunk,word):
- rev_string = chunk[::-1]
- rev_regex = word[::-1]
- trimmed = re.sub(rev_regex, '', rev_string)[::-1]
- # print final
- if trimmed != chunk:
- return recurse(trimmed, word)
- else:
- return trimmed
- def answer(chunk, word):
- print recurse(chunk, word)
- return recurse(chunk, word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement