sw expert academy-1989. 초심자의 회문 검사-python

cosmos·2022년 4월 12일
0
post-thumbnail

풀이

  • python의 슬라이싱을 활용하면 쉽게 구현할 수 있다.

코드

# https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PyTLqAf4DFAUq&categoryId=AV5PyTLqAf4DFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=PYTHON&select-1=2&pageSize=10&pageIndex=1
# sw expert academy, d2: 1989. 초심자의 회문 검사, python3
def solve(word: str) -> int:
    return 1 if word == word[::-1] else 0

if __name__ == '__main__':
    t = int(input())

    for i in range(1, t+1):
        word = str(input())
        print('#' + str(i) + ' ' + str(solve(word)))

결과

출처 & 깃허브

1989. 초심자의 회문 검사
github

0개의 댓글