practice.py
657 Bytes
a = '[노브랜드] 미네랄 워터 생수 (2L x 6개입)'
while True:
b = a.find('[')
c = a.find(']')
if b == -1:
break
elif b == 0:
a = a[c + 1:-1]
else:
break
while True:
d = a.find('(')
e = a.find(')')
if d == -1:
break
elif d == 0:
a = a[e + 1:-1]
else:
break
result = ''
b = list(a)
for i in b:
if (ord(i) < 48) or (ord(i) > 57):
if i == ' ':
continue
result += i
else:
break
while True:
if (result[-1] == '(') or (result[-1] == '[') or (result[-1] == ' '):
result = result[0:-1]
else:
break