A set is an unordered collection of data type that it iterable, mutable, and has no duplicate elements.Python's set class represents the mathematical notion of a set.This is based on data Structure known as hash table.

We can use Set to check all elements are same or not in a list because of its property which restricts the duplicate element in a set.

#set a pointer to check
def checkList(myList):
return len(set(myList)) == 1
# Driver Code
myList = ['harry', 'harry', 'harry', 'harry']
if checkList(myList) == True:print("Equal")
else: print("Not Equal")

Equal

## Comments