how to remove vowels from a string in python code example
Example 1: python method to filter vowels in a string
def anti_vowel(c):
newstr = c
vowels = ('a', 'e', 'i', 'o', 'u')
for x in c.lower():
if x in vowels:
newstr = newstr.replace(x,"")
return newstr
Example 2: how to remove voules out of a string
import java.util.Scanner;
public class RemoveVowelsUsingMethod
{
static String removeVowel(String strVowel)
{
Character[] chVowels = {'a', 'e', 'i', 'o', 'u','A','E','I','O','U'};
List<Character> li = Arrays.asList(chVowels);
StringBuffer sb = new StringBuffer(strVowel);
for(int a = 0; a < sb.length(); a++)
{
if(li.contains(sb.charAt(a)))
{
sb.replace(a, a + 1, "");
a--;
}
}
return sb.toString();
}
public static void main(String[] args)
{
String strInput = "Flower Brackets";
System.out.println(removeVowel(strInput));
}
}
Example 3: remove vowels in a string python
# removing vowels in a string
def anti_vowel(c):
newstr = c
vowels = ('a', 'e', 'i', 'o', 'u')
for x in c.lower():
if x in vowels:
newstr = newstr.replace(x,"")
return newstr