If I have a list containing both numbers and non-numbers, such as
{1,2,3,4,5,6p6,7p7,8,9}
how do I locate the positions in the list which do not contain numbers. So for the above example, I am looking for the output {{6},{7}}
. I want to use the position command, but I don't know what pattern to specify.
Thanks in advance for any help.
Position[{1,2,3,4,5,6 p6,7 p7,8,9}, Except[_?NumberQ], {1}, Heads -> False]
? $\endgroup$Rest@Position[l, Except[_Integer], {1}]
? $\endgroup$Heads -> False
is much better thanRest
. Ben's answer is much more idiomatic than mine. $\endgroup$Position
isMapIndexed[If[Not[NumericQ[lis[[First[#2]]]]], #2, Nothing] &, lis]
gives{{6}, {7}}
$\endgroup$