Collections.deque()

  • + 21 comments

    Nice one!

    Here is my attempt. 'args' can be of any length(0 or more).

    from collections import deque
    d = deque()
    for _ in range(int(input())):
        cmd, *args = input().split()
        getattr(d, cmd)(*args)
    [print(x, end=' ') for x in d]