Write a Python function that takes a list and returns a new list with unique elements of the first list
example 1:-
def unique_list(l):
x = []
for a in l:
if a not in x:
x.append(a)
return x
print(unique_list([1,2,3,3,3,3,4,5]))
output:-
[1, 2, 3, 4, 5]
example 2:-
def unique_list(l):
num = []
for a in l:
if a not in num:
num.append(a)
return num
print('unique elements are')
print(unique_list([1,2,4,5,4,5,6,9,10]))
output:-
unique elements are
[1, 2, 4, 5, 6, 9, 10]
>>>
Post a Comment
If you have any doubts, Please let me know
Thanks!