Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import re
- import random
- def prepare_to_british_scientists(text, letters_to_shuffle_nm):
- def count(match):
- line = match.group(0)
- if(len(line) <= 3):
- return line
- changing = min(letters_to_shuffle_nm, len(line) - 2)
- mylist =[s for s in line[1:1+changing]]
- random.shuffle(mylist)
- return line[0] + ''.join(mylist) + line[1+changing:]
- a = re.sub(r'[a-zA-z]+|[а-яА-Я]+', count , text)
- return a
Add Comment
Please, Sign In to add comment