This question has already been answered:
- Remove unique values from list 3 responses
There is a piece of code:
def remitem(mylist): mylist2=mylist for item in mylist: if (mylist.count(item)==1): mylist2.remove(item) return mylist2 print remitem([5, 6, 7, 8, 9]) Please tell me why he returns [6,8], then the cycle goes through one list, and deletes it from another - according to logic, does it have to return []?