CBSE Class 11 Computer Science Question 78 of 91

String Manipulation — Question 2

Back to all questions
2
Question

Question 2

Write a program which replaces all vowels in the string with '*'.

Solution
str = input("Enter the string: ")
newStr = ""
for ch in str : 
    lch = ch.lower()
    if lch == 'a' \
       or lch == 'e' \
       or lch == 'i' \
       or lch == 'o' \
       or lch == 'u' :
        newStr += '*'
    else :
        newStr += ch
print(newStr)
Output
Enter the string: Computer Studies
C*mp*t*r St*d**s
Answer