-
Notifications
You must be signed in to change notification settings - Fork 0
/
01_parentheses.py
50 lines (39 loc) · 1.09 KB
/
01_parentheses.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
#!/usr/bin/env python3
#Joshua Ching;The program will print argv with every other letter capitalized.
#Then, will replace each capitalized vowel with a '*' and then tell you if '(' and ')' are balanced
#By Joching
#IMPORTANT: argv MUST start and end with -> "
#---------------------------------------------------
import sys
def main():
rlist = ''
e = 0
arg = sys.argv[1]
arg = str(arg)
for i in arg:
if i == '(':
rlist = rlist + i
elif i == ')':
rlist = rlist + i
elif i == ' ':
rlist = rlist + i
elif e == 1:
rlist = rlist + i
e = 0
else:
i = i.upper()
rlist = rlist + i
e = 1
print(rlist)
relist = rlist
for x in relist:
if x == 'O' or x == 'E' or x == 'A' or x == 'I' or x == 'U':
relist = relist.replace(x,'*')
print(relist)
opencount = relist.count('(')
closecount = relist.count(')')
if opencount == closecount:
print('Balanced? True')
else:
print('Balenced? False')
main()