Tuesday, September 29, 2009

Python - generate double dutch

# this example is similar 
# to the double dutch generator 
def createDoubleDutch(word):
        create and return a double 
        dutch version of word 
    for v in ("a", "e", "i", "o", "u", "y"):
        # double dutch-ize each vowel 
        word = word.replace(v, v+"b"+v)
    return word
if __name__ == '__main__':
    ddSentence = "" 
    for w in "My sample sentence for double dutch".split(' '):
           ddSentence += createDoubleDutch(w) + " " 
    print ddSentence.strip()
# Myby sabamplebe sebentebencebe fobor doboubublebe dubutch 

No comments:

Post a Comment