[Tutor] Messy - Very Messy string manipulation.
Vusa Moyo
soweto at gmail.com
Wed Oct 28 11:09:59 EDT 2015
Hi Guys,
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?
----
def anti_vowel(text):
vowel = ['a', 'e', 'i', 'o', 'u']
VOWEL = ['A', 'E', 'I', 'O', 'U']
manip = []
for i in text:
manip.append(i)
fufu = 0
#
while fufu < 16:
for x in vowel:
if x in manip:
manip.remove(x)
for y in VOWEL:
if y in manip:
manip.remove(y)
fufu = fufu + 2
strong = ''.join(manip)
return strong
----
Thanks - Vusa
More information about the Tutor
mailing list