Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple recursion solution in Clear category for Middle Characters by Kolia951
def middle(text: str) -> str:
""" Returns middle of the given text"""
if len(text) == 1 or len(text) == 2:
return text
else:
return middle(text[1:-1])
print("Example:")
print(middle("example"))
assert middle("example") == "m"
assert middle("test") == "es"
print("The mission is done! Click 'Check Solution' to earn rewards!")
Dec. 12, 2022
Comments: