0
Q:

python remove duplicate numbers

def remove_dupiclates(list_):
	new_list = []
	for a in list_:
    	if a not in new_list:
        	new_list.append(a)
	return new_list
1
mylist = ["a", "b", "a", "c", "c"]
mylist = list(dict.fromkeys(mylist))
4
def remove_consecutive_duplicates(_list: list):
    preprocessed_list = []
    for x in itertools.groupby(_list):
        preprocessed_list.append(x[0])

    return preprocessed_list
1
duplicate = [2, 4, 10, 20, 5, 2, 20, 4] 
print(list(set(duplicate))
0
word = input().split()

for i in word:
  if word.count(i) > 1:
    word.remove(i)
1

  def my_function(x):
  return list(dict.fromkeys(x))

mylist = 
  my_function(["a", "b", "a", "c", "c"])

  
print(mylist) 
0

New to Communities?

Join the community