input: Write a function to find the total number of common characters present in both strings. If the given strings are empty then return 0.
  def num_common_chars(str1, str2):
      common = 0
      str2_set = set(str2)
      for c in str1:
          if c in str2_set:
              common += 1
      return common
  
  assert num_common_chars("hello", "world")==3
  assert num_common_chars("foo", "bar")==0
  assert num_common_chars("aaaa", "aa")==2
  assert num_common_chars("", "test")==0
  assert num_common_chars("test", "")==0
  assert num_common_chars("", "")==0
output: def num_common_chars(str1, str2):
      common = 0
      str2_set = set(str2)
      for c in str1:
          if c in str2_set:
              common += 1
      return common