Collections.deque()

  • + 0 comments

    The shortest code I could come with. I wonder if it could be shorter.

    from collections import deque
    
    d = deque()
    for _ in range(int(input())):
        cmd, *attribute = input().split()
        eval(f'd.{cmd}({(attribute[0:1] or ('',))[0]})')
    print(*d)