Python program that takes a string and count the number of vowels and replace them with '*' character.

Python Program

Write a program with a function that takes a string as an argument; the function counts the number of vowel characters in the string and replace them with ‘*’ character. The function should print the old string (all characters should be capitalized), the new string, and the number of vowel characters in the string. The program should let the user enter a string and pass it to the function.

Sample output:

page1image5956544

def string():
     vowels = 0
     str1 = input(str(“Enter a string: “))
     r = “AEIOU”
     old = str1.upper()
     new = ” “
     for e in old:
         if e not in r:
             new = new + e
         else:
             new = new + “*”
     print(“Old String: “, old)
     print(“New String: “, new)
     for i in str1:
         if (i == ‘a’ or i == ‘e’ or i == ‘i’ or i == ‘o’ or i == ‘u’ or i == ‘A’ or i == ‘E’ or i == ‘I’ or i == ‘O’ or i == ‘U’):
             vowels = vowels + 1
     print(“Number of vowel characters: “, vowels)
string()