forked from csev/py4e
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtypos.py
More file actions
28 lines (25 loc) · 572 Bytes
/
typos.py
File metadata and controls
28 lines (25 loc) · 572 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
fn = raw_input("Enter name: ");
fh = open(fn);
count = 0;
lastword = None
for line in fh:
count = count + 1
words = line.split()
for word in words:
if len(word) > 3 :
ch1 = word[0:1]
ch2 = word[1:2]
ch3 = word[2:3]
if ch1 >= 'A' and ch1 <= 'Z' and ch2 >= 'A' and ch2 <= 'Z' and ch3 >= 'a' and ch3 <= 'z' :
print count, word
if len(word) < 2 :
lastword = word
continue
word = word.lower()
ch = word[0:1]
if ch < 'a' or ch > 'z' :
lastword = word
continue
if lastword == word:
print count, word, lastword
lastword = word