Exercise 73
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"
Solution
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'
Younes Derfoufi
my-courses.net
[…] Exercie 73 || Solution […]