PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from random import sample
sentence = input("Enter sentence: ")
list_of_words = sentence.split(' ')
typo = ''
for word in list_of_words:
if len(word) > 3:
if word.isalpha():
typo += word[0] + ''.join(sample(word[1:-1], len(word)-2)) + word[-1] + ' '
elif word.isdigit():
typo += word + ' '
else:
typo += word[0] + ''.join(sample(word[1:-2], len(word)-3)) + word[-2:] + ' '
else:
typo += word + ' '
print("\n\nInput: ", sentence)
print("Output: ", typo)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run