Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Second_Approach solution in Clear category for Between Markers (simplified) by santhosh_malay
#Approach -1
#def between_markers(text: str, begin: str, end: str) -> str:
# return text[text.find(begin)+1 :text.find(end) ]
#Approach -2
between_markers = lambda m, n, o, func = lambda x, y :x.find(y) : m[func(m, n)+1 : func(m,o)]
if __name__ == '__main__':
print('Example:')
print(between_markers('What is >apple<', '>', '<'))
# These "asserts" are used for self-checking and not for testing
assert between_markers('What is >apple<', '>', '<') == "apple"
assert between_markers('What is [apple]', '[', ']') == "apple"
assert between_markers('What is ><', '>', '<') == ""
assert between_markers('>apple<', '>', '<') == "apple"
print('Wow, you are doing pretty good. Time to check it!')
Sept. 17, 2019