I was writing a function to remove duplicate integers in a list, but I don't think I did it the most efficient way possible. Any suggestions?
def remove_dups(items):
new_list = sorted(items)
i_postion = 0
if len(new_list) > 1:
for i in new_list:
counter = 1
while counter < len(new_list):
if i_postion + counter < len(new_list):
if new_list[i_postion] == new_list[i_postion + counter]:
new_list.remove(new_list[i_postion + counter])
counter += 1
i_postion += 1
#A check if the list is only one number multiple times
if new_list[0] == new_list[1]:
new_list.remove(new_list[1])
else:
return(new_list)
return(new_list)