0
Can anyone help me please? In a random list how to remove all negative elements coming before min element of a list
8 Respostas
0
say the list was l = [1,-6,3,78,-4]
you could do
for i in l:
if i < 0:
l.remove(i)
print (l)
0
it deletes all negative elements but I want to delete negative elements coming before min(smallest) element
0
but if you are taking the smallest element theres no element smaller...
0
thats what I mean.... if there is delete it else let it be
0
but you could edit it so its
if i < m where m is the min number you define
0
oh good idea
0
i got confused because you used the function min() in your scentence and that takes the smallest number in a list
0
i mean if we have: [10, -3, -4, -6]
output: [10, -6]
but if we have [10, -6, -3, -4]
then do nothing