-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgather3.py
74 lines (68 loc) · 1.84 KB
/
gather3.py
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import sys
def gather_digit(filename):
array, files = [], open(filename)
for lines in files:
lists = lines.rstrip().split()
for i in range(0, len(lists), 1):
word = lists[i]
for j in range(0, len(word), 1):
if word[j].isdigit() == True:
array.append(word[j])
return ''.join(array)
i += 1
files.close()
def gather_lower(filename):
array, files = [], open(filename)
for lines in files:
lists = lines.rstrip().split()
for i in range(0, len(lists), 1):
word = lists[i]
for j in range(0, len(word), 1):
if word[j].islower() == True:
array.append(word[j])
return ''.join(array)
i += 1
files.close()
def gather_upper(filename):
array, files = [], open(filename)
for lines in files:
lists = lines.rstrip().split()
for i in range(0, len(lists), 1):
word = lists[i]
for j in range(0, len(word), 1):
if word[j].isupper() == True:
array.append(word[j])
return ''.join(array)
i += 1
files.close()
def gather_upper_digit(filename):
array, files = [], open(filename)
for lines in files:
lists = lines.rstrip().split()
for i in range(0, len(lists), 1):
word = lists[i]
for j in range(0, len(word), 1):
if word[j].isupper() == True or word[j].isdigit() == True:
array.append(word[j])
return ''.join(array)
i += 1
files.close()
def gather_lower_digit(filename):
array, files = [], open(filename)
for lines in files:
lists = lines.rstrip().split()
for i in range(0, len(lists), 1):
word = lists[i]
for j in range(0, len(word), 1):
if word[j].islower() == True or word[j].isdigit() == True:
array.append(word[j])
return ''.join(array)
i += 1
files.close()
if __name__ == '__main__':
filename = sys.argv[1]
print(gather_digit(filename))
print(gather_lower(filename))
print(gather_upper(filename))
print(gather_upper_digit(filename))
print(gather_lower_digit(filename))