1406 에디터 파이썬

강지훈·2022년 6월 14일
0

string=list(input())
cursor=len(string)

n=int(input())
for _ in range(n):
cmd=list(input().split())
if cmd[0]=='P':
string.insert(cursor,cmd[1])
cursor+=1
elif cmd[0]=='L':
if cursor > 0:
cursor-=1
elif cmd[0]=='D':
if cursor < len(string):
cursor+=1
else:

    # cmd[0]=='B':
    if cursor > 0:
        string.remove(string[cursor-1])

print(''.join(string))

profile
never stop

0개의 댓글