/ Published in: Python

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# scheme: (define (downup wd) (if (= (count wd) 1) (se wd) (se wd (downup (bl wd)) wd))) > (downup 'toe) (TOE TO T TO TOE) > (downup 'banana) (BANANA BANAN BANA BAN BA B BA BAN BANA BANAN BANANA) # now in python def downup(word): if len(word) == 1: return [word] return [word] + downup(word[1:]) + [word] print downup("bananas")
Comments
