Simple Text Editor

  • + 0 comments
    x = ['']
    for s in [input() for _ in range(int(input()))]:
        x.append(x[-1]+s[2:]) if s[0] == '1' else x.append(x[-1][:-int(s[2:])]) if s[0] == '2' else print(x[-1][int(s[2:])-1]) if s[0] == '3' else x.pop() if s == '4' else ...