Set .add()

Sort by

recency

|

962 Discussions

|

  • + 0 comments
    def distinct_stamps(N,names):
        return len(set(names))
        
    if __name__ == "__main__":
        N = int(input())
        names= []
        for _ in range(0,N):
            names.append(str(input()))
        result = distinct_stamps(N,names)
        print(result)
    
  • + 0 comments

    This is as simple as I could make it:

    N=int(input())
    countries=set([input() for _ in range(N)])
    print(len(countries))
    
  • [deleted]Challenge Author
    + 0 comments

    For Python3

    N = int(input())
    stamps = set()
    for i in range(N):
        stamps.add(input())
    
    print(len(stamps))
    
  • + 0 comments

    import sys

    num_stamps = int(sys.stdin.readline()) stamps = {sys.stdin.readline().rstrip() for _ in range(num_stamps)} sys.stdout.write(str(len(stamps)))

  • + 0 comments

    n =int(input()) s=set() for i in range(n): t=input()
    s.add(t) print(len(s))