+ 1
How to count the number of non-repeating items in a python list?
For example: a=[1,2,3,3] #there’s two ‘3’ print(len(a)) #it’s not valid 3
3 Respuestas
+ 4
There is a function for that, set() function transforms lists into a set, which removes all repeating values.
So: len(ser(a)) = 3
+ 2
Thanks
+ 2
A set just removes the duplicate, you want the count of "unique" values (unless i misunderstand your question)..so..
a = [1, 2, 3, 3]
counter = 0
for x in a:
if a.count(x) == 1:
counter += 1
print(counter)