Suppose we have a string, we have to remove all vowels from that string. So if the string is like “iloveprogramming”, then after removing vowels, the result will be − "lvprgrmmng"
To solve this, we will follow these steps −
- create one array vowel, that is holding [a,e,i,o,u]
- for v in a vowel
- replace v using blank string
Example
Let us see the following implementation to get a better understanding −
class Solution(object): def removeVowels(self, s): s = s.replace("a","") s = s.replace("e","") s = s.replace("i","") s = s.replace("o","") s = s.replace("u","") return s ob1 = Solution() print(ob1.removeVowels("iloveprogramming"))
Input
"iloveprogramming"
Output
lvprgrmmng