Answer to Question #346165 in Python for Bylapati suresh kumar

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


1
Expert's answer
2022-05-30T08:17:22-0400
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS