Where's my value?
Pyth, 2 bytes
0-indexed.
xE
Try it online! or Check all the Test Cases
Explanation
xEQ - Full Program. Takes Input from standard input. Q means evaluated input and is implicit at the end of the program.
x - Get all the indexes of x in y
E - Evaluated Input #2 - The value
Q - The list - Evaluated Input #1
Python 3, 45 bytes
-3 bytes thanks to @EriktheOutgolfer and @Chris_Rands
lambda y,x:[i for i,j in enumerate(x)if j==y]
Test Suite.
Today I learned enumerate(x) == zip(range(len(x)),x)
.
Python 3, 47 bytes
lambda n,l:[x for x in range(len(l))if l[x]==n]
Try it online! or Check all the Test Cases
MATL, 2 bytes
mf
The m
consumes two arguments, and checks each element in the array whether is equal to the other argument, f
returns the indices of the truthy entries of an array.
Try it online!