Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Between Markers (simplified) solution in Uncategorized category for Between Markers (simplified) by Aleksandra_Niewiadomska
def between_markers(text: str, start: str, end: str) -> str:
start_index = text.find(start) + len(start)
end_index = text.find(end)
if start_index > end_index:
return ""
else:
return text[start_index:end_index]
print("Example:")
print(between_markers("What is >apple<", ">", "<"))
# These "asserts" are used for self-checking
assert between_markers("What is >apple<", ">", "<") == "apple"
assert between_markers("What is [apple]", "[", "]") == "apple"
assert between_markers("What is ><", ">", "<") == ""
assert between_markers("[an apple]", "[", "]") == "an apple"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Feb. 1, 2023