An easy way to do this is to use numpy ravel and then install:
import numpy as np lst = [(2, 5), (3, 5), (2, 5)] res = list(set(np.ravel(a)))
gives:
[2, 3, 5]
Reply to Apero comment:
If you do not want to use numpy, you can flatten the list with:
lst = [(2,5), (3,5), (2,5)] tmp = [] for i in lst: for j in i: tmp.append(j) res = set(tmp) print res
which gives:
[2, 3, 5]
source share