- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this tutorial, we are going to find the indices of the numbers that are greater than the given number K. Let's see the different ways to find them.

A most common way to solve the problem is using the loops. Let's see the steps to solve the problem.

- Initialize the list and K.
- Iterate over the list using its length.
- If you find any number greater than K, then print the current index.

# initializing the list and K numbers = [3, 4, 5, 23, 12, 10, 16] K = 10 # iterating over thAe list for i in range(len(numbers)): # checking the number greater than K if numbers[i] > K: # printing the number index print(i, end=' ')

If you run the above code, then you will get the following result.

3 4 6

Let's solve the problem using **enumerate** function. It gives you a tuple for each iteration that includes the element's index and element.

# initializing the list and K numbers = [3, 4, 5, 23, 12, 10, 16] K = 10 # finding indexes of the numbers greater than K result = [index for (index, number) in enumerate(numbers) if number > K] # printing the indices print(*result)

If you run the above code, then you will get the following result.

3 4 6

If you have any doubts in the tutorial, mention them in the comment section.

- Related Questions & Answers
- Python – Average of digit greater than K
- Python - Consecutive Ranges of K greater than N
- Python – Remove characters greater than K
- Python - Number of values greater than K in list
- Find smallest element greater than K in Python
- Python – Filter Tuples Product greater than K
- Python - Get the Index of first element greater than K
- Python – Remove Tuples with difference greater than K
- Python – Extract dictionaries with values sum greater than K
- Count of alphabets having ASCII value less than and greater than k in C++
- Python – Extract list with difference in extreme values greater than K
- Largest subarray having sum greater than k in C++
- Program to split lists into strictly increasing sublists of size greater than k in Python
- Count of subarrays whose maximum element is greater than k in C++
- Python – Find the frequency of numbers greater than each element in a list

Advertisements