Write a program with a user defined program with string as a parameter which replaces all
vowels in the string with "*"
Attachments:
Answers
Answered by
0
vowels = ['a','e','i','o','u']
def replaceVowels(str):
str = list(str)
replacedStr = map(lambda x: '*' if x in vowels else x, str)
print(''.join(replacedStr))
inp = input('Enter string: ')
replaceVowels(inp)
Answered by
9
The following codes have been written using Python.
#defining a function
def vowel_replace(string):
#starting a loop to traverse through the characters
for i in string:
#checking for the required characters
if i in "aeiouAEIOU":
#replacing the required characters with an asterisk
string = string.replace(i, "*")
#printing the final output
print(string)
#obtaining input from a user
string = input("Enter a string: ")
#calling the function on the input
vowel_replace(string)
Similar questions
Math,
1 month ago
Math,
1 month ago
Social Sciences,
2 months ago
Geography,
2 months ago
Biology,
9 months ago
Psychology,
9 months ago