im doing this problem where you input the number of commands then input the commands and then the program runs it.
the answer was:
from collections import deque
d = deque()
for _ in range(int(input())):
method, *n = input().split()
getattr(d, method)(*n)
print(*d)
Im confused on how this for loop manages to run the commands inputted. Can anyone explain this ? Ex: you would input 1(3 of commands) and then append 1(commands) and then it would output the deque after the command: 1