HackerRank Python- Set add




Set .add()

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 N country stamps.

Find the total number of distinct country stamps.



  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. if __name__ == "__main__":
  3. N = int(input().strip())
  4. stamps = set()
  5. for _ in range(N):
  6. stamp = input().strip()
  7. stamps.add(stamp)
  8. print(len(stamps))
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube