import random class Word(object): def __init__(self, word): self.word = word def jumble(self): result = "" while self.word: index = random.randrange(len(self.word)) letter = self.word[index] self.word = self.word[:index] + self.word[index+1:] result = result + letter self.word = result def report(self): return self.word w = Word("five") for i in range(10): w.jumble() print w.report() print text = "I've watched the stars fall silent from your eyes\n" + \ "All the sights that I have seen\n" + \ "I can't believe that I believed I wished\n" + \ "That you could see\n" + \ "There's a new planet in the solar system\n" + \ "There is nothing up my sleeve\n\n" + \ "I'm pushing an elephant up the stairs\n" + \ "I'm tossing up punch lines that were never there\n" + \ "Over my shoulder a piano falls\n" + \ "Crashing to the ground\n" print text text = text.split() for elem in text: elem = Word(elem) elem.jumble() print elem.report(), if random.randrange(1, 6) == 4: print