Answer to Question #311618 in Python for Rohit

Question #311618

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

1
Expert's answer
2022-03-15T02:57:58-0400
def main():    #Read string    inputString = input("Enter string: ")    outputString=""    for letter in inputString:        number=getNumber(letter)        if(number!=-1):            outputString+=str(number)+"-"        else:            outputString+=letter    print(outputString[:-1])#This function convert letter to numberdef getNumber(letter):    alphabet = "abcdefghijklmnopqrstuvwxyz"    for i in range(0,len(alphabet)):        if letter.islower() and letter==alphabet[i]:            return i+1        if letter.isupper() and letter==alphabet[i].upper():            return i+1    return -1main()

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