i wrote this program :
l = []
N = int(input("enter the size of the list"))
if N < 50:
for i in range(N):
a = int(input("add a number to the list"))
l.append(a)
for i in range(N):
del l[min(l)]
print(l)
and when i run it they say
Traceback (most recent call last):
File "<pyshell#5>", line 2, in <module>
del l[min(l)]
IndexError: list assignment index out of range
please do you have any solutions ??
del l[min(l)]? Consider a list[10, 20, 30]now image the execution ofdel l[min(l)]. This would bedel l[10], but there is not 10th element in the list and hence shows errordel l[min(l)]is equivalent todel l[23], which is equivalent to "delete the 24th element of l". But l doesn't have 24 elements, it has three elements.