d_skat

Untitled

Apr 22nd, 2018
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. import sys
  2. import re
  3. import random
  4.  
  5.  
  6. def prepare_to_british_scientists(text, letters_to_shuffle_nm):
  7.     def count(match):
  8.         line = match.group(0)
  9.         if(len(line) <= 3):
  10.             return line
  11.         changing = min(letters_to_shuffle_nm, len(line) - 2)
  12.         mylist =[s for s in line[1:1+changing]]
  13.         random.shuffle(mylist)
  14.         return line[0] + ''.join(mylist) + line[1+changing:]
  15.     a = re.sub(r'[a-zA-z]+|[а-яА-Я]+', count , text)
  16.     return a
Add Comment
Please, Sign In to add comment