[백준] #2941 if문으로 예외 처리 python

2022. 12. 22. 17:13

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

 

2941번: 크로아티아 알파벳

예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z=

www.acmicpc.net

too many if ~....

 

S = input()

if 'c=' in S:
    S = S.replace('c=', '|')
if 'c-' in S:
    S = S.replace('c-', '|')
if 'dz=' in S:
    S = S.replace('dz=', '|')
if 'd-' in S:
    S = S.replace('d-', '|')
if 'lj' in S:
    S = S.replace('lj', '|')
if 'nj' in S:
    S = S.replace('nj', '|')
if 's=' in S:
    S = S.replace('s=', '|')
if 'z=' in S:
    S = S.replace('z=', '|')
print(len(S))

BELATED ARTICLES

more