Remove array duplicates
Write a function that receives a list (array) as a parameter, and deletes its duplicate items and returns the new (array) list
Write a function that receives a list (array) as a parameter, and deletes its duplicate items and returns the new (array) list
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error' alert(msg)This answer is only visible to premium members
This answer is only visible to premium members
def remove (list):
repeat = []
for x in list:
if x not in repeat:
repeat.append(x)
print (repeat)
l=[]
def list1(h):
p=set(h)
h=list(p)
return h
while True:
a=input("Enter list members:\n")
if a=="":
break
l.append(a)
print(list1(l))
def Removeduplicate(lst): return list(set(lst)) print(Removeduplicate(lst=input("Enter list elements: ").split(',')))
def a(*num):
while True:
b = input("num:")
if b == "":
break
i = set(num)
i.add(b)
num = list(i)
return num
print(a())
def remove_duplicates(input_list): """این تابع آیتمهای تکراری را از لیست حذف کرده و لیست جدیدی برمیگرداند.""" # Use set (SET) to remove duplicates unique_list = list(set(input_list)) return unique_list # Example of the use of function original_list = [1, 2, 3, 4, 2, 3, 5, 1, 6] new_list = remove_duplicates(original_list) print("لیست اصلی:", original_list) print("لیست بدون تکراری:", new_list)
def hazf(x): y = set(x) y = list(y) return y lists = [] while True: x = input('kalame ra vared konod ya jahat moshahede faghat enter bezanid: ') if x == '': print(f'without : {hazf(lists)}') break lists.append(x)
def num(x): a = list(set(x)) return a print(num([3 , 5 , 8 , 5]))
Submitting answers is currently unavailable.
You must be logged in to access this section.
Login/Sign up If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.