-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_add.py
More file actions
30 lines (23 loc) · 1 KB
/
set_add.py
File metadata and controls
30 lines (23 loc) · 1 KB
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
#!/bin/python3
# Set .add() Challenge Solution
# problem link: https://www.hackerrank.com/challenges/py-set-add/problem
# Author: Audity Ghosh
# Date: 21 January 2020
# Description:
# This script helps Rupal count the total number of distinct country stamps
# in her collection. The task is to find the total number of distinct
# country stamps after applying the .add() operation on a set.
# Read the total number of country stamps
t=int(input()) # The total number of country stamps
# Initialize an empty list to store the country names
data=[]
# Loop through each input country name
for i in range(t):
k=input() # Read the name of the country where the stamp is from
data.append(k) # Add the country name to the list
# Convert the list to a set to remove duplicates
s=set(data)
# Convert the set back to a list to count the distinct country stamps
l=list(s)
# Print the total number of distinct country stamps
print(len(l)) # Output the length of the set (distinct countries)