0

What is the pythonic way to check how many different kinds of elements in python list. something like:

lst = [1, 1, 2, 2, 3, 3, 4, 4]
s = set()        
for l in lst:
    s.add(l) 
result = list(s)
Jim
  • 769
  • 3
  • 10
  • 22
  • Almost. Instead of adding each item individually just use `set(lst)`. And to find out how many items there are, use `len()`. – mkrieger1 Mar 13 '19 at 12:49
  • actually I want to know what is the value. I just want to know if I could make it in one or two lines – Jim Mar 13 '19 at 12:51

0 Answers0