Set Add() in Python | HackerRank Programming Solutions | HackerRank Python Solutions

Hello Programmers/Coders, Today we are going to share solutions of Programming problems of HackerRank of Programming Language Python. At Each Problem with Successful submission with all Test Cases Passed, you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight your profile to the recruiters.

In this post, you will find the solution for Set Add() in Python-HackerRank Problem. We are providing the correct and tested solutions of coding problems present on HackerRank. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

Introduction To Python

Python is a widely-used, interpreted, object-oriented, and high-level programming language with dynamic semantics, used for general-purpose programming. It was created by Guido van Rossum, and first released on February 20, 1991.

Python is a computer programming language often used to build websites and software, automate tasks, and conduct data analysis. It is also used to create various machine learning algorithm, and helps in Artificial Intelligence. Python is a general purpose language, meaning it can be used to create a variety of different programs and isn’t specialized for any specific problems. This versatility, along with its beginner-friendliness, has made it one of the most-used programming languages today. A survey conducted by industry analyst firm RedMonk found that it was the most popular programming language among developers in 2020.

Link for the ProblemSet Add() in Python – HackerRank Solution

Set Add() in Python – HackerRank Solution

If we want to add a single element to an existing set, we can use the .add() operation.
It adds the element to the set and returns ‘None‘.


>>> s = set('HackerRank')
>>> s.add('H')
>>> print s
set(['a', 'c', 'e', 'H', 'k', 'n', 'r', 'R'])
>>> print s.add('HackerRank')
>>> print s
set(['a', 'c', 'e', 'HackerRank', 'H', 'k', 'n', 'r', 'R'])


Apply your knowledge of the .add() operation to help your friend Rupal.

Rupal has a huge collection of country stamps. She decided to count the total number of distinct country stamps in her collection. She asked for your help. You pick the stamps one by one from a stack of  country stamps.

Find the total number of distinct country stamps.

Input Format

The first line contains an integer , the total number of country stamps.
The next  lines contains the name of the country where the stamp is from.


Output Format

Output the total number of distinct country stamps on a single line.

Sample Input

New Zealand

Sample Output



UK and France repeat twice. Hence, the total number of distinct country stamps is  (five).

Set Add() in Python – HackerRank Solution
Set.Add() in Python - Hacker Rank Solution 
# Python 3
# Enter your code here. Read input from STDIN. Print output to STDOUT
# Set.Add() in Python - Hacker Rank Solution START
N = int(input())

countries = set()

for i in range(N):

# Set.Add() in Python - Hacker Rank Solution END

1 thought on “Set Add() in Python | HackerRank Programming Solutions | HackerRank Python Solutions”

  1. Hi, Neat post. There is a problem with your web site in internet explorer, would test this… IE still is the market leader and a big portion of people will miss your magnificent writing due to this problem.


Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker🙏.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock