Wednesday, December 5, 2018

python - From a string, how do you return only the words that don't begin with a vowel?

I have a string E.g. "A dog is a good pet"



I would like to be able to return only the words that begin with a consonant. ["dog", "good", "pet"] as a list



def consonant_first(newstr):
for char in newstr.split():
if char[0] in newstr.split() == vowels1:
return newstr.split()

print(newstr)

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...