๐ Day 58/150 – Find Unique Elements in a List in Python
Unique elements are values that appear only once in the list.
Example:
[1, 2, 2, 3, 4, 4, 5] → Unique elements = [1, 3, 5]
Let’s explore different ways to find them ๐
๐น Method 1 – Using Loop
๐น Method 2 – Using List Comprehension
numbers = [1, 2, 2, 3, 4, 4, 5]
unique = [num for num in numbers if numbers.count(num) == 1]
print("Unique Elements:", unique)
๐น Method 3 – Using collections.Counter
๐น Method 4 – Taking User Input
numbers = list(map(int, input("Enter numbers: ").split())) unique = [num for num in numbers if numbers.count(num) == 1] print("Unique Elements:", unique)


