Tuples and sets · 8 / 16 Exercise Easy

Remove duplicates

Objective

Create a Python program that removes the repeated values from a series of numbers using a set.

Instructions

  • Read an integer n and then n integers, one per line.
  • Store them in a set to keep the distinct values.
  • On the first line show the distinct values sorted from smallest to largest, separated by a space.
  • On the second line show Unique values: K, with the number of distinct values.
Input
6
4
2
4
2
7
1
Output
1 2 4 7
Unique values: 4

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise