The short answer . You should probably use First@Position [...]
Long answer: Let's divide the question into 2 parts:
Why do you have an extra {} result for Position ?
i.e. why:
lis = {1, 2}; Position[lis, 1]
returns {{1}} ?
This is in order to work sequentially with an n-dimensional list, which can have the requested values ββin several positions. For instance:
lis = {{1, 2, 3}, {1, 5, 6}, {1, 2, 1}}; Position[lis, 1]
returns {{1, 1}, {2, 1}, {3, 1}, {3, 3}}
which is a list of coordinates, the result is found. So in your case:
lis = {1, 2}; Position[lis, 1]
return {{1}} , as in: we found your requested value once, at coordinate {1} .
Mathematica many times now assumes that there may be a list of solutions (for example, in Solve ), but the user knows that he expects only one. The appropriate code for this in your case would be First@Position [...] . this will return the first (and, presumably, only) element in the list of positions - So, if you are sure that the element you are looking for exists only once in the list and want to know where, use this method.
Why do you have an extra {} result for Extract ?
Extract can work in two different ways.
If I do Extract[{{a, b, c}, {d, e, f}, {g, e, h}}, {1, 2}] I get b , so extracting with a 1-dimensional list just selects and returns this item. Indeed, Extract[lis, {1, 2}] equals lis[[1, 2]]
If I do Extract[{{a, b, c}, {d, e, f}, {g, e, h}}, {{1, 2}, {3, 4}}] I get {b, h} , so extraction with a 2-dimensional list selects and returns a list of elements.
In your case (s), you do Extract[lis, {{1}}] , as in: give me a list containing only the lis[[1]] element. The result is always this element in the list, which is optional {}