Python Practice › List Programs › Program 71

Are all elements unique?

EasyList Programs · 71 of 100

Write a Python program to check whether all elements of a list are unique.

Advertisement
Input
[2, 5, 6, 7, 4, 11, 2, 4, 66, 21, 22, 3]
Output
False

Approach

  1. A set has the same length only if nothing repeated.

Solution

Python
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.

More list programs

← All 100 List Programs

Leave a Comment