Write a python function that takes a string ‘s’ as parameter and which delete all vowels from the string ‘s’. Example: if s = “Python is hight level programming language”, the algorithm returns the string: “Pthn s hght lvl prgrmmng lngg”
def remove_vowels(s): # define all vowels in the following string: vowels = "AEYIOUaeyiou" # initialize an empty string result that will be used to build the final string without vowels. result = "" # we then loop through each character in the input string s for char in s: if char not in vowels: result += char return result # Example of use of this algorithm: s = "Python is hight level programming language" result = remove_vowels(s) print(result) #output: 'Pthn s hght lvl prgrmmng lngg'
One thought on “Solution Exercise 73: python algorithm that remove all vowels from a given string”
[…] Exercie 73 || Solution […]