๐ Python/๋ฐฑ์ค
[5622]๋ค์ด์ผ
Jayden1116
2022. 3. 12. 20:46
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)