Answer to Question #187154 in Python for Hari nadh babu

Question #187154

Given a string, write a program to print a secret message that replaces characters with numbers 'a' with 1, 'b' with 2, ..., 'z' with 26 where characters are separated by '-'.


Note: You need to replace both uppercase and lowercase characters. You can ignore replacing all characters that are not letters.


Input:-

The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).


Output:-

The output should be a single line containing the secret message. All characters in the output should be in lower case.


For Example -

Input 1:-

python


Output 1:-

16-25-20-8-15-14


Input 2:-

Foundations

Output 2:-

6-15-21-14-4-1-20-9-15-14-19


1
Expert's answer
2021-04-29T12:10:05-0400
#get text from the user
text=input("Enter a text: ")
text=text.lower() #convert the text to lower case

output=[] #initialize a list to store the numbers

for character in text:
    number=ord(character)-96
    output.append(number)

s = [str(i) for i in output]
s="-".join(s)
print("Secret message:",s)

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
New on Blog
APPROVED BY CLIENTS