Light Mode
Dark Mode
Why is it not working?
def between_markers(text: str, begin: str, end: str) -> str:
    word = ''
    if text.find(begin) and text.find(end) > 0:
        for i in text[text.find(begin) + len(begin):text.find(end):]:
            word += i
        return word
    elif text.find(begin) != -1 and text.find(end) == -1:
        for i in text[text.find(begin) + len(begin):text[-1]:]:
            word += i
        return word
    elif text.find(begin) == -1 and text.find(end) != -1:
        for i in text[:text.find(end):]:
            word += i
        return word
    elif text.find(begin) > text.find(end):
        return word
    else:
        return text

I really can not understand why my code is not working in "No[/b] hi" It returns me nothing (empty string - '') I can understand why, because i wrote third elif special for this cases~

Created: Feb. 29, 2020, 2:07 p.m.
Updated: March 1, 2020, 8:56 a.m.
0
11
User avatar
sanayeon