Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

331
Views
¿Cómo encontrar los índices de elementos en una lista, que están presentes en otra lista?

Quiero usar esencialmente una lista, es decir.

 L = [10, 10, 100, 10, 17, 15]

y usando otra lista

 R = [10, 15]

quiero volver

 N = [0, 1, 3, 5] // indices of L that return the values in R

Intenté usar L.index() para obtener los índices, pero eso solo devuelve el primer valor. Luego intenté ejecutar un bucle for sobre L y usar L.index(R[0]) cada vez, pero de manera similar solo devuelve los primeros índices que encuentra.

 for i in range(len(L)): j = R[i] N.append(L.index(j)) return N

Esto devolvería el índice fuera de rango, lo que tiene sentido, pero ¿cómo hago para que se ejecute a través de L ?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

N = [] for i in range(len(L)): if L[i] in R: N.append(i)

o con un generador

 N = [i for i in range(len(L)) if L[i] in R]

o con arreglos

 import numpy as np N=np.where(np.isin(L,R))
over 4 years ago · Santiago Trujillo Report

0

N = [] for i, num in enumerate(L): if num in R: N.append(i)
over 4 years ago · Santiago Trujillo Report

0

[i for i,l in enumerate(L) if l in R]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!