input: Write a function to count the total number of common characters present in both strings. The function should take two strings as input and return the count as an integer. If either of the strings is empty, the function should return 0.
  
  def num_common_chars(str1, str2):
      common = 0
      for c in str1:
          if c in str2:
              common += 1
      return common
  
  assert num_common_chars("hello", "world")==2
  assert num_common_chars("aaaa", "aaab")==3
  assert num_common_chars("abc", "def")==0
  assert num_common_chars("", "hello")==0
  assert num_common_chars("hello", "")==0
output: def num_common_chars(str1, str2):
      if not str1 or not str2:
          return 0
      common = 0
      for c in set(str1):
          if c in str2:
              common += min(str1.count(c), str2.count(c))
      return common