Nov-21-2020, 10:18 PM
Hello guys,
I'm new on the forum. The reason I'm here is that I do not know how to fix my problem and hopefully you can help me.
I want to delete the maximum element from the list with the command "remove". I know that remove, removes the first element that I choose to remove, so I made a loop so if there are two or more maximum elements, all of them should be removed.
It doesn't work. It seems like the loop doesn't go through all elements.
I'm new on the forum. The reason I'm here is that I do not know how to fix my problem and hopefully you can help me.
I want to delete the maximum element from the list with the command "remove". I know that remove, removes the first element that I choose to remove, so I made a loop so if there are two or more maximum elements, all of them should be removed.
It doesn't work. It seems like the loop doesn't go through all elements.
def list(a): c=max(a) a.remove(c) for i in a: print(i) if i == c: a.remove(i) if a[len(a)-1] == c: a.pop(len(a)-1) return a print(list([1,2,3,4,5,6,6,6,6,6,6,6,6,6]))