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 ^
Answers:
I think using sub()
from re may help you.
Code :
mydetails = re.sub(r'a|e|i|o|u','',mystr)
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)
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 ^
I think using sub()
from re may help you.
Code :
mydetails = re.sub(r'a|e|i|o|u','',mystr)
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)