Problem

2 /10


Set Methods

Theory Click to read/hide

Methods for working with sets


Number of elements in the set
The len() method returns the number of elements in the set. k = {42, 'foo', 3.14159, None, (1, 2, 3)}  print(len(k))    #5

 

Determining if an element is in a set (membership in)
k = {42, 'foo', 3.14159, None, (1, 2, 3)}  print(42 in k)    # True print(2 in k)     # False
Although the elements contained in a set must be of an immutable type, the sets themselves can be changed. 

 

Adding an element to set
x.add(<elem>)
to the set  x adds <elem> which must be the only immutable object.

 

Removing an element from a set
1) x.remove(<elem>)
<elem>  is removed from the x set. Python throws an exception (error) if <elem> is not in x.

2) x.discard(<elem>)
the same deletes, but in case of absence of an element in the set, it does not raise an exception.

3) x.pop()
removes and returns a random element from the set. If the set is initially empty, then an exception (error) occurs.

4) x.clear()
removes all elements from the set (clears the set).

Problem

Deniska thinks that he can say how many unique numbers in the sequence that Mishka came up with. Help Denis. Write a program for him that will do all the calculations for him.

(You can write a program in Python in one line. Try it!)

Input
The input is a sequence of numbers.

Imprint 
Print on the screen how many distinct numbers occur in the sequence. 

 
Examples
# Input Output
1 4 5 7 2 3 3 2  5