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
#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)
Comments
Leave a comment