get rid of duplicate elements in list without set

MRAB google at mrabarnett.plus.com
Fri Mar 20 11:27:19 EDT 2009


Tino Wildenhain wrote:
> thomasvangurp at gmail.com wrote:
>> You could use:
>> B=list(set(A)).sort()
>> Hope that helps.
> 
> That would leave a B with value None :-)
> 
> B=list(sorted(set(A))
> 
> could work.
> 
sorted() accepts an iterable, eg a set, and returns a list:

B = sorted(set(A))



More information about the Python-list mailing list