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))

download android app