When you do:
print itemgetter(id)(z)
you are passing a list
to itemgetter
, while it expects indices (integers).
What can you do? You can unpack the list
using *
:
print itemgetter(*id)(z)
to visualize this better, both following calls are equivalent:
print itemgetter(1, 2, 3)(z)
print itemgetter(*[1, 2, 3])(z)