Posted on 19th May 2025|38 views
How can I count the number of unique values within a list in python?
Posted on 19th May 2025| views
You can count the number of unique values within the list just by using set() and len() just like this
x_list = [1, 1, 2, 2, 3, 4, 4]
x_set = set(x_list)
unique_values = len(x_set)
print(unique_values)
Output:
4