/* ............... START ............... */
# Method 1: Using a Set
# Input list
my_list = [1, 2, 2, 3, 4, 4, 5]
# Convert the list to a set to remove duplicates
unique_values = set(my_list)
# Convert the set back to a list if needed
unique_list = list(unique_values)
print(unique_list)
# Method 2: Using a List Comprehension
# Input list
my_list = [1, 2, 2, 3, 4, 4, 5]
# Create a list with unique values using a list comprehension
unique_list = [x for x in my_list if my_list.count(x) == 1]
print(unique_list)
# Method 3: Using a Loop
# Input list
my_list = [1, 2, 2, 3, 4, 4, 5]
# Initialize an empty list to store unique values
unique_list = []
# Iterate through the original list
for x in my_list:
# If the value is not already in the unique_list, add it
if x not in unique_list:
unique_list.append(x)
print(unique_list)
# Method 4: Using the collections.Counter class
from collections import Counter
# Input list
my_list = [1, 2, 2, 3, 4, 4, 5]
# Create a Counter object to count occurrences
counter = Counter(my_list)
# Extract unique values from the Counter object
unique_list = [item for item, count in counter.items() if count == 1]
print(unique_list)
/* ............... END ............... */