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
| def solution(s):
answer = 0
bowl_list = []
bowl = ''
for i in range(len(s)):
if s[i].isdigit() == True or s[i] == 'Z' or s[i] == '-':
bowl += s[i]
elif s[i] == ' ':
if bowl == 'Z':
bowl_list.append(bowl)
else:
bowl_list.append(int(bowl))
bowl = ''
if bowl.isdigit() == True:
bowl_list.append(int(bowl))
else:
bowl_list.append(bowl)
for j in range(len(bowl_list)):
if bowl_list[j] != 'Z':
answer += bowl_list[j]
else:
answer -= bowl_list[j-1]
return answer
|