How to print all letter except mentioned letters

Question:

I am trying to find all letters except this mentioned letters 'a|e|i|o|u'

import re 
mystr ='love to code'
mydetails = re.findall(^'a|e|i|o|u',mystr)

So my output should be like below which should not be vowels letters

l v t c d 

But this not is not working ^

Asked By: yyy62103

||

Answers:

I think using sub() from re may help you.

Code :

mydetails = re.sub(r'a|e|i|o|u','',mystr)
Answered By: Rupal Shah
mystr ='love to code'
char_to_remove = ['a','e','i', 'o', 'u']

mydetails = ' '.join([l for l in mystr if l not in char_to_remove])

print (mydetails)
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.