[Tutor] Messy - Very Messy string manipulation.

Peter Otten __peter__ at web.de
Wed Oct 28 12:37:09 EDT 2015


Vusa Moyo wrote:

> I've written a script to remove vowels from a string/sentence.
> 
> the while loop I'm using below is to take care of duplicate vowels found
> in a sentence, ie
> 
> anti_vowel('The cow moos louder than the frog')
> 
> It works, but obviously its messy and n00by. Any suggestions on how I can
> write this code better?

(I'm assuming Python3)

>>> 'The cow moos louder than the frog'.translate(str.maketrans("", "", 
"aeiouAEIOU"))
'Th cw ms ldr thn th frg'




More information about the Tutor mailing list