Question #346165

pager


imagine a pager with only one button for the letter "A" you press the button one time for "B"ou press it two times for "E" you press it five times ,for "G" its pressed seven times





explanation :

for example if the given strings abcde , then

the total number of times the button pressed 1+2+4+5


so the output is 12


input: abde

output: 12


intput:xyz

output:75


Expert's answer

inp = list(input())
alphabet = list('abcdefghijklmnopqrstuvwxyz')
out = 0
for i in range(len(inp)):
    for j in range(26):
        if inp[i] == alphabet[j]:
            out += j + 1
print(out)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS