You are viewing a single comment's thread. Return to all comments →
def TextEditor(ops): s='' done=[] for i in ops: if i[0]=='1': s=s+(i[1]) done.append(i) elif i[0]=='2': e=s[(len(s)-int(i[1])):len(s)] s=s[0:(len(s)-int(i[1]))] i.append(e) done.append(i) elif i[0]=='3': print(s[int(i[1])-1]) elif i[0]=='4': u=done[-1] if u[0]=='1': s=s[0:(len(s)-len(u[1]))] elif u[0]=='2': s=s+(u[2]) done.pop() return q=int(input()) ops=[] for i in range(q): ops.append(input().split()) TextEditor(ops)
Seems like cookies are disabled on this browser, please enable them to open this website
Simple Text Editor
You are viewing a single comment's thread. Return to all comments →