Tech Study

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

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

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more