프로그래밍/알고리즘

가운데 글자 가져오기

로퍼. 2021. 6. 20. 01:01
def solution(word):
    length = len(word)
    if length % 2 == 1:
        return word[length // 2]
    else:
        return word[length//2 - 1 : length//2 + 1]