Python checks for duplicates in a list

Python checks for duplicates in a list

def isUnique(t): 
	return len(t) == len(set(t))

a = [1,1,2,2,3,2,3,4,5,6] 
b = [1,2,3,4,5] 
isUnique(a) # False 
isUnique(b) # True

Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example