Python Practice › List Programs › Program 71
Are all elements unique?
Write a Python program to check whether all elements of a list are unique.
Input
[2, 5, 6, 7, 4, 11, 2, 4, 66, 21, 22, 3]
Output
False
Approach
- A set has the same length only if nothing repeated.
Solution
items = [2, 5, 6, 7, 4, 11, 2, 4, 66, 21, 22, 3]print(len(set(items)) == len(items))Output
False
Learn the concept
New to this topic? Read the lesson, then come back.