PRACTICE

Sets & Uniqueness

Lesson notes

Your task

Use a set to remove duplicates from [3, 1, 3, 2]. Print the unique values as a sorted list.

Expected output
[1, 2, 3]
Loading…

OUTPUT

Worked solution
numbers = [3, 1, 3, 2]
print(sorted(set(numbers)))

Checks compare printed output, not your approach. Several solutions can be valid.

← Back to courses