-
Notifications
You must be signed in to change notification settings - Fork 15
/
gather-upper-digit.py
60 lines (55 loc) · 1.48 KB
/
gather-upper-digit.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
import sys
def gather_digit(filesname):
array, files = [], open(filesname)
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(filesname):
array, files = [], open(filesname)
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(filesname):
array, files = [], open(filesname)
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(filesname):
array, files = [], open(filesname)
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()
if __name__ == '__main__':
filesname = sys.argv[1]
print(gather_digit(filesname))
print(gather_lower(filesname))
print(gather_upper(filesname))
print(gather_upper_digit(filesname))