import sys
alp_arr = sys.stdin.readline().rstrip()
time_tot = 0
for alp in alp_arr:
if alp in 'ABC':
time_tot += 3
elif alp in 'DEF':
time_tot += 4
elif alp in 'GHI':
time_tot += 5
elif alp in 'JKL':
time_tot += 6
elif alp in 'MNO':
time_tot += 7
elif alp in 'PQRS':
time_tot += 8
elif alp in 'TUV':
time_tot += 9
else:
time_tot += 10
print(time_tot)
๋ค๋ฅธ ํ์ด
alpabet_list = ['ABC','DEF','GHI','JKL','MNO','PQRS','TUV','WXYZ']
word = input()
time = 0
for unit in alpabet_list :
for i in unit: # alpabet ๋ฆฌ์คํธ์์ ๊ฐ ์์๋ฅผ ๊บผ๋ด์ ํ๊ธ์์ฉ ๋ถ๋ฆฌ
for x in word : # ์
๋ ฅ๋ฐ์ ๋ฌธ์๋ฅผ ํ๋์ฉ ๋ถ๋ฆฌ
if i == x : # ๋ ์ํ๋ฒณ์ด ๊ฐ์ผ๋ฉด
time += alpabet_list.index(unit) +3 # time = time + index +3
print(time)
'๐ Python > ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[1316]๊ทธ๋ฃน ๋จ์ด ์ฒด์ปค (0) | 2022.03.13 |
---|---|
[2941]ํฌ๋ก์ํฐ์ ์ํ๋ฒณ (0) | 2022.03.12 |
[1157]๋จ์ด ๊ณต๋ถ (0) | 2022.03.08 |
[10809]์ํ๋ฒณ ์ฐพ๊ธฐ (0) | 2022.03.08 |
[11720]์ซ์์ ํฉ (0) | 2022.03.08 |