-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathg.py
17 lines (16 loc) · 885 Bytes
/
g.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import random
with open("e:\\InputFile.txt") as input_file ,open ("e:\\OutputFile.txt","w") as output_file:
for line in input_file.readlines():
scrmble_line_list =[]
for word in line.strip().split(' '):
if len(word) >3:
if word[-1]=='.' or word[-1]=='?' or word[-1]==';' or word[-1]=='!5':
word = word[0]+''.join(random.sample(word[1:-2],len(word)-3))+word[-2:]
else:
word = word[0]+''.join(random.sample(word[1:-1],len(word)-2))+word[-1]
scrmble_line_list.append(word)
scrmble_line=' '.join(scrmble_line_list)
scrmble_line= scrmble_line + '\n'
output_file.write(scrmble_line)
input_file.close()
output_file.close()