Here is a code I have written. I presumed both of them to return the same answer but they don't! How are they different?
from collections import deque
d = deque()
for _ in range(int(input())):
method, *n = input().split()
getattr(d, method)(*n)
print(*d)
and
from collections import deque
d = deque()
for _ in range(int(input())):
method, *n = input().split()
d.method(*n)
print(*d)
getattr(...)will get a named attribute from an object;getattr(x, 'y')is equivalent tox.y.Where as
d.method(*n)will try to lookup the method namedmethodindequeobject result inAttributeError: 'collections.deque' object has no attribute 'method'