본문 바로가기

프로그래머스/Python

[프로그래머스] PCCE 기출문제 - 4번 / 병과분류 (Python)

문제

문제링크

환자 코드의 마지막 4글자에 따라 병과가 정해진다.

마지막 글자 병과
"_eye" "Ophthalmologyc"
"head" "Neurosurgery"
"infl" "Orthopedics"
"skin" "Dermatology"
# 빈칸 채우기 문제
code = input()
last_four_words = code[-4:]

if last_four_words == [   ]:
    print("Ophthalmologyc")
elif [   ]:
    print("Neurosurgery")
elif [   ]:
    print("Orthopedics")
[   ]:
    print("Dermatology")
[   ]:
    print("direct recommendation")

 

코드

code = input()
last_four_words = code[-4:]

if last_four_words == "_eye":
    print("Ophthalmologyc")
elif last_four_words == "head":
    print("Neurosurgery")
elif last_four_words == "infl":
    print("Orthopedics")
elif last_four_words == "skin":
    print("Dermatology")
else:
    print("direct recommendation")