Advertisement
Guest User

The Deeper Zen of Python

a guest
Dec 12th, 2011
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3.  
  4. from this import s, d
  5. from random import shuffle
  6.  
  7. assert('I kid, because I love.' != False)
  8.  
  9. print("\nAnd now for something completely different\n")
  10.  
  11. txt = ''
  12. for char in s:
  13.     char = d.get(char, char)
  14.     txt += char
  15.  
  16. txt = txt.split()
  17. shuffle(txt)
  18.  
  19. current_line = '  '
  20. for word in txt:
  21.     if len(current_line) + len(word) > 78:
  22.         print(current_line)
  23.         current_line = word
  24.     else:
  25.         current_line += ' ' + word
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement