Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- import re
- line = input()
- extra_spaces = re.compile(r'(?<= ) +')
- need_space = re.compile(r'([\.\?\!])(?![ ])')
- eol_space = re.compile(r'(?<=[\.\?\!]) +$')
- lower = re.compile(r'((?<=[A-Z])[a-zA-Z]*[a-z][a-zA-Z]*|(?<=[a-z])[a-zA-Z]+)')
- while(line != ""):
- line = extra_spaces.sub("",line)
- line = need_space.sub(r'\1 ', line)
- line = eol_space.sub("",line)
- line = lower.sub(lambda x: x.group(0).lower(),line)
- print (line)
- line = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement