자기개발👨‍💻/코딩 알고리즘

[python] 백준 1259 팰린드롬수

천숭이 2020. 8. 29. 13:23

https://www.acmicpc.net/problem/1259

 

5613번: 계산기 프로그램

입력의 각 줄에는 숫자와 +, -, *, /, =중 하나가 교대로 주어진다. 첫 번째 줄은 수이다. 연산자의 우선 순위는 생각하지 않으며, 입력 순서대로 계산을 하고, =가 주어지면, 그때까지의 결과를 출��

www.acmicpc.net

result=[]
while(1):
    inp=input()
    if inp == "0":
        break
    inp=list(inp)
    length = int(len(inp)/2)

    if len(inp)%2==0:
        front = inp[0:length]
        back = inp[length:]
    else:
        front = inp[0:length]
        back = inp[length+1:]  
              
    if front == back[::-1]:
        result.append("yes")
    else:
        result.append("no")

for i in result:
    print(i)