Skip to main content
1 of 6
pxeger
  • 24.6k
  • 4
  • 53
  • 141

Python 2, 50 bytes

a,x=input()
while x in a:print a.index(x);a.pop(0)

Attempt This Online!

Python, 51 bytes

f=lambda a,x:[1]*(x in a)and[a.index(x)]+f(a[1:],x)

Attempt This Online!

pxeger
  • 24.6k
  • 4
  • 53
  • 141