Friday, July 10, 2009

Python remove vowels from a sentence

# create a tuple with vowels....yes I include y as a vowel
vowels = 'a', 'e', 'i', 'o', 'u', 'y'

# movie quote for our sentence
sentence = "My name is Werner Brandes, my voice is my password, verify me."


# iterate through the tuple of vowels
for vowel in vowels:
    # replace the vowel with nothing

    sentence = sentence.replace(vowel, '')

# display the vowel-less sentence!
print sentence

'M nm s Wrnr Brnds, m vc s m psswrd, vrf m.'


# additional string functions: http://docs.python.org/library/stdtypes.html

# manipulate vowels to create pig latin or double dutch


No comments:

Post a Comment

Post a Comment