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


Introduction

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.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. def unique_list(l):
  2. num = []
  3. for a in l:
  4. if a not in num:
  5. num.append(a)
  6. return num
  7. print('unique elements are')
  8. print(unique_list([1,2,4,5,4,5,6,9,10]))

Result

python language techstudy.org

     





Related Topics




Popular Posts