Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
"Middle Characters" solution in Uncategorized category for Middle Characters by Mateusz_Wryszcz
def middle(text: str) -> str:
length = len(text)
if length % 2 == 0:
return text[length // 2 - 1:length // 2 + 1]
return text[length // 2]
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. 20, 2022
Comments: