I was searching for an answer for this question but couldn't find it. I am posting a answer. Hope it helps someone in the future. Program is tested and works. n = count of numbers to remove from the list
Asked
Active
Viewed 232 times
-1
-
1Does this answer your question? [fastest method of getting k smallest numbers in unsorted list of size N in python?](https://stackoverflow.com/questions/33623184/fastest-method-of-getting-k-smallest-numbers-in-unsorted-list-of-size-n-in-pytho) – sanjeevRm Jun 16 '21 at 11:38
1 Answers
0
numbers_list = input().split()
n = int(input())
for i in range(len(numbers_list)): # converts it from string to integers
numbers_list[i] = int(numbers_list[i])
for i in range(n):
min_element = min(numbers_list)
numbers_list.remove(min_element)
for i in range(len(numbers_list)): # converts it again from integers to string
numbers_list[i] = str(numbers_list[i])
print(", ".join(numbers_list))

Dilyan
- 39
- 1
- 1
- 8