
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove Vowels from a String in Python
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
Advertisements