Advertisement
here2share

# b_filter_string2.py

Mar 3rd, 2020
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # b_filter_string2.py
  4. from random import *
  5.  
  6. zzz = '''
  7. Python
  8. Programming
  9. Is
  10. Lots
  11. Of
  12. Fun
  13.  
  14. These
  15. are
  16. what
  17. words
  18. that
  19. remain
  20. from
  21. having
  22. to
  23. remove
  24. all
  25. the
  26. extra
  27. data
  28. '''.strip().splitlines()
  29.  
  30. abc = 'abcdefghijklmnopqrstuvwxyz'
  31. p = ['\n','-'] + [z for z in abc.upper()+abc.lower()]
  32. for z in range(33,256):
  33.     if chr(z) not in p:
  34.         for i in 'z'*9:
  35.             L = len(zzz)
  36.             x = sorted(zzz,key=len)
  37.             x = choice(x[:L/5])
  38.             x = zzz.index(x)
  39.             r = randint(0, len(zzz[x]))
  40.             t = list(zzz[x])
  41.             t.insert(r, chr(z))
  42.             zzz[x] = ''.join(t)
  43. 0
  44. zzz = '\n'.join(zzz)
  45. print zzz
  46.  
  47. t = set(zzz)
  48. for z in t:
  49.     if z not in p:
  50.         zzz=zzz.replace(z,'')
  51. 0
  52. print
  53. print zzz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement