HackerRank Python - Set union Operation




The .union() operator returns the union of a set and the set of elements in an iterable.
Sometimes, the | operator is used in place of .union() operator, but it operates only on the set of elements in set.
Set is immutable to the .union() operation (or | operation).



  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. n = input()
  3. eng = set(map(int,input().split()))
  4. b = input()
  5. fre = set(map(int,input().split()))
  6. print(len(eng.union(fre)))




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