Collections.deque()

  • + 0 comments

    command , value = input().split()

    Commands like "pop" and "popleft" that after split() have just one element. So there haven't enough values to assign to the variable value. It will cause ValueError.


    command , value, *arg = input().split() + ['']

    the variable with * can assigned zero or more values.

    • If command is "pop", the [''] in the last assigned to value.
    • If command is "append 1", the "1" assigned to value and the [''] in the last assigned to arg.