I faced some problem with solving the next problem:
We have a list of elements (integers), and we should return a list consisting of only the non-unique elements in
Would it not be easier to generate a new list?
def unique_list(lst): new_list = [] for value in lst: if value not in new_list: new_list.append(value) return new_list lst = [1,2,3,1,4,5,1,6,2,3,7,8,9] print(unique_list(lst))
Prints [1,2,3,4,5,6,7,8,9]