Write a Python program to access a function inside a function

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.

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

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

Add a Comment

Your email address will not be published. Required fields are marked *