Loading...

Python Tutorial for Beginners #3 | 3 Ways to Get Unique Values From a List #python

223 6________

How to Get Unique Values from
Given a list
numbers = [1,3,4,2,5,4,3,2,2,5,6]

1. Python Set() to Get Unique Values from a List
set_res = set(numbers)

2. Using Dictionary Method
set_dict = { i for i in numbers }

3. Use Built-in Counter method from collections
set_cou = {*Counter(numbers)}

コメント