Let’s create a list that will only have unique elements. In other words, we will add value only if there is no same value inside our list.
Inside the code, there is the for a loop. This loop iterates through each element of the list_of_elements list and checks whether the value is already inside the unique_list list. If it’s not present, the program adds this element. Otherwise, it returns False and checks the next iteration.
If you run this code, you are going to get the following result:
As you can see, there are no duplicates – each value is unique.