지나가던 개발자

[Python] 백준 4659번(비밀번호 발음하기) 문제 풀이 본문

PS/Python

[Python] 백준 4659번(비밀번호 발음하기) 문제 풀이

KwonYongHyeon 2022. 11. 14. 18:35

 

while True:
    pw = input()
    if pw == "end":
        break
    if "a" not in pw and "i" not in pw and "u" not in pw and "e" not in pw and "o" not in pw:
        print("<"+pw+"> is not acceptable.")
        continue
    if "aa" in pw or "bb" in pw or "cc" in pw or "dd" in pw or "eee" in pw or "ff" in pw or "gg" in pw or "hh" in pw or "ii" in pw or "jj" in pw or "kk" in pw or "ll" in pw or "mm" in pw or "nn" in pw or "ooo" in pw or "pp" in pw or "qq" in pw or "rr" in pw or "ss" in pw or "tt" in pw or "uu" in pw or "vv" in pw or "ww" in pw or "xx" in pw or "yy" in pw or "zz" in pw:
        print("<"+pw+"> is not acceptable.")
        continue
    moum = ['a','e','i','o','u']
    ima = ''
    inARow = 0
    printed = False
    for i in pw:  #rqeuya
        if i in moum:
            if ima == '':
                inARow += 1
                ima = "moum"
            elif ima == "moum":
                inARow += 1
            else:
                ima = "moum"
                inARow = 1
        else:
            if ima == '':
                inARow += 1
                ima = "jaum"
            elif ima == "jaum":
                inARow += 1
            else:
                ima = "jaum"
                inARow = 1
        if inARow >= 3:
            print("<"+pw+"> is not acceptable.")
            printed = True
            break
    if not printed:
        print("<"+pw+"> is acceptable.")
Comments