Question
def doOperations(a, b): c = abcdefghijklmnopqrstuvwxyz d = ABCDEFGHIJKLMNOPQRSTUVWXYZ e = AEIOU f = aeiou if a == 'A': print(len(b), characters) elif a == 'B':
def doOperations(a, b): c = "abcdefghijklmnopqrstuvwxyz" d = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" e = "AEIOU" f = "aeiou" if a == 'A': print(len(b), "characters") elif a == 'B': count = 0 for i in range(len(b)): if b[i] in c or b[i] in d: count = count + 1 print(count, "letters") elif a == 'C': count = 0 for i in range(len(b)): if b[i] in e or b[i] in f: count = count + 1 print(count, "vowels") elif a == 'D': found = 1 i = 0 j = len(b) - 1 while i < j: if b[i] != b[j] : found = 0 break i = i + 1 j = j - 1 if found == 1: print("It is a palindrome") else: print("It is not a palindrome") elif a == 'E': ct = "" for i in range(len(b)): for j in range(len(c)): if c[j] == b[i]: j = j - 3 if j < 0: j = 26 + j ct = ct + c[j] for j in range(len(d)): if d[j] == b[i]: j = j - 3 if j < 0: j = 26 + j ct = ct + d[j] print(ct)
def printMenu(): print("A.How many characters are in the string?") print("B.How many letters are in the string?") print("C.How many vowels are in the string?") print("D.Is the string a palidrome?") print("E.What is the Cesar Cipher(shift 3) of the string")
inp = input("Enter a string :") while True: printMenu() response = input("Your choice?") if response == 'Q': break doOperations(response, inp)
Can someone fix the code to make it
When a person executes your program, your program should ask the person to enter a string. Next, the following menu should appear:
A. How many characters are in the string?
B. How many letters are in the string?
C. How many vowels are in the string?
D. Is the string a palindrome?
E. What is the Caesar Cipher (shift 3) of the string?
Q. Quit
Once the person makes a choice, the program should perform the requested task. If the person chooses Q, then the program should terminate. Otherwise, the process should continueask the user for another string, print the menu, get a choice, etc.
For the purposes of this assignment, you may assume that a string is a palindrome only if it is exactly the reverse of itself. Thus, "rats live on no evil star" will be a palindrome, but "sit on a potato pan, Otis." will not.
Also, let's pretend that the letter y is never a vowel.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started