Computer Science, asked by sahil9191, 1 year ago

Write a Python function that takes a list and returns a new list with unique elements of the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]

Don't dare to give useless answer ​

Answers

Answered by Anonymous
6

Answer:

Write a Python function that takes a list and returns a new list with unique elements of the first list.

my_list = [10, 20, 30, 40, 20, 50, 60, 40]

print("Original List : ",my_list)

my_set = set(my_list)

my_new_list = list(my_set)

print("List of unique numbers : ",my_new_list)

Explanation:


sahil9191: thx
Answered by Anonymous
13

Answer:

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]))

hope it help ✌️


sahil9191: \ (•◡•) / thanks for your answer
Similar questions