카테고리 없음

백준 10809번 : 알파벳 찾기 (Python,파이썬)

에르미타쥬 2018. 12. 24. 00:54

1

2

3

4

5

6

7

8

9

10

11

alpha_bet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

alpha_bet_two = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

word = ' '.join(input()).split()

index = 0

for i in alpha_bet:

if i in word:

alpha_bet[alpha_bet.index(i)] = str(word.index(i))

for i in alpha_bet:

if i in alpha_bet_two:

alpha_bet[alpha_bet_two.index(i)] = '-1'

print(' '.join(alpha_bet))

순서대로 알파벳이 나열되어있는 리스트를 만들었다. 입력 단어에 쓰인 알파벳이 알파벳 리스트에 있다면 리스트 내 알파벳을 입력 단어에 쓰인 순서 번호로 바꿔주어 출력했다.