How to find the indexes of numbers greater than N in a list with Python

1 Answer

0 votes
lst = [3, 8, 14, 30, 9, 7, 21]
 
N = 8

result = [idx for idx, val in enumerate(lst) if val > N]
 
print(result)




'''
run:

[2, 3, 4, 6]

'''

 



answered Mar 2, 2023 by avibootz
...