-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathset_add.py
61 lines (43 loc) · 1.18 KB
/
set_add.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Problem Statement
If we want to add a single element to an existing set, then we can use .add() operation.
It adds element to the set and returns 'None'.
Example
>>> s = set('HackerRank')
>>> s.add('H')
>>> print s
set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])
>>> print s.add('HackerRank')
None
>>> print s
set(['a', 'c', 'e', 'HackerRank', 'H', 'k', 'n', 'r', 'R'])
Task
Apply your knowledge of .add() operation, to help your friend 'Hari'.
Hari has a huge collection of country stamps. He decided to count total number of distinct country stamps he has collected. He asked you to help him. You pick stamps one by one from a stack of 'N' country stamps.
Your task is to find the total number of distinct country stamps.
Input Format
First line contains N, total number of country stamps.
Next N lines contains, names of the country stamp.
Constraints
0<N<1000
Output Format
Output the total number of distinct country stamps.
Sample Input
7
UK
China
USA
France
New Zealand
UK
France
Sample Output
5
Explanation
UK and France are repeating twice. Hence, total number of distinct country stamps is 5 (five).
"""
a = input()
b = set()
for i in xrange(a):
b.add(raw_input())
print len(b)