본문 바로가기
Beakjoon&프로그래머스/파이썬

[프로그래머스/파이썬] 가운데 글자 가져오기

by 현장 2021. 4. 24.

-코드

def solution(s):
    ans = ''
    if len(s) % 2 == 1:
        ans = s[len(s)//2]
    else:
        ans = s[len(s)//2 - 1:len(s)//2+1]
    return ans