29 июля 2021
ACPФотография
For this, you're using the remove function wrongly.
I think the remove function works with a loop, and it breaks the loop when it finds the element you want to remove.
ACPФотография
Since you're a for loop, I'll recommend tracking the index number and using the pop method to achieve this.
ACPI don't want to create newlist ...
You don't have to
Just iterate through the list and keep track of your index number, when you take an element off the list, the list gets smaller, so your next element is the same index as the last, so you don't increase the index after using the pop function.
The index is so you can tell your pop function where the element is
ACPI think pop will work but I'm curious how this code is working ...after removing first element last element would be shifted to second last and loop will not check this.......
This code is actually implemented to break after it has removed the first occurrence. That's why it exits the loop. And I don't think it's just a break that's added. Maybe something else that terminates any other loop it's nested in cause I think the function itself is a list
ACPI think last element would never be checked ......if perform remove method on duplicate members of list
I guess it's cause they're following eachother. I tried using a different list and it removed everything
ACPInterestingly I had this issue long back with my code that time I had avoided remove method ...
Lol... Good find
I don't think I have really used the remove method though. Thanks for the eye opener