arg
Not a cry of frustration at yet another error message, but rather, an abbreviation for argument, and also the name of a built-in metalogical predicate, that extracts arguments from a structure. Example:

?- arg(2, buys(john, beer), Arg).
Arg = beer

It is also possible to put arguments into terms using arg, should this prove useful:

?- X = likes(mary, Y), arg(2, X, pizza).
X = likes(mary, pizza)
Y = pizza