You can do it:
Input = {4.0, 4.1, 4.2, 4.0, 9.0, 9.4, 8.9, 4.3} wl=sorted(Input,reverse=True) apr=.1 out={} while wl: wn=wl.pop() out[wn]=[wn] while wl and wl[-1]<=wn*(1+apr): out[wn].append(wl.pop()) print [(k,out[k]) for k in sorted(out.keys())]
Fingerprints:
[(4.0, [4.0, 4.1, 4.2, 4.3]), (8.9, [8.9, 9.0, 9.4])]
Try the example in the comments:
>>> Input = {1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0}
Print
[(1.0, [1.0, 1.1]), (1.2, [1.2, 1.3]), (1.4, [1.4, 1.5]), (1.6, [1.6, 1.7]), (1.8, [1.8, 1.9]), (2.0, [2.0])]