forked from tony9402/baekjoon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
41 lines (34 loc) · 885 Bytes
/
main.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
# Authored by : shjeong92
# Co-authored by : -
# Link : http://boj.kr/c6cb199947f24b69ab8c425987c63d1c
import sys
def input():
return sys.stdin.readline().rstrip()
data = input()
answer = ''
temp=[]
length = len(data)
inParen = False
for i in range(length):
if data[i] == '<':
inParen = True
elif data[i] == '>':
inParen = False
if inParen and data[i] == '<' :
if temp:
answer += ''.join(temp[::-1])+'<'
temp=[]
else:
answer +='<'
elif inParen and data[i] != '<':
answer += data[i]
elif not inParen and data[i] =='>':
answer += data[i]
elif not inParen and data[i]!= ' ':
temp.append(data[i])
elif not inParen and data[i]== ' ':
answer += ''.join(temp[::-1])+' '
temp=[]
if temp:
answer+= ''.join(temp[::-1])
print(answer)