Set .add()

Sort by

recency

|

983 Discussions

|

  • + 0 comments
    s=int(input())
    s1=set()
    count=0
    for i in range(s):
        ctry=input()
        s1.add(ctry)
    for x in s1:
        count+=1
    print(count)
    
  • + 0 comments

    Here is HackerRank Set .add() in python solution - https://programmingoneonone.com/hackerrank-set-add-problem-solution-in-python.html

  • + 0 comments

    print(len(set([input() for i in range(int(input()))])))

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    n = int(input())
    output_set = set()
    for i in range(n):
        element = input()
        output_set.add(element)
    
    print(len(output_set))
    
  • + 0 comments
    N=int(input())
    s=set()
    for i in range (N):
            s.add(input())
    print(len(s))