Write a Python function that takes a list and returns a new list with unique elements of the first list
I have used python 3.7 compiler for debugging purpose.
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]))
Result:
unique elements are
[1, 2, 4, 5, 6, 9, 10]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
I have used python 3.7 compiler for debugging purpose.
Result:
unique elements are
[1, 2, 4, 5, 6, 9, 10]
need an explanation for this answer? contact us directly to get an explanation for this answer