input: Write a function to find the total number of common characters present in both strings. Given two strings, the function should iterate through each character of the first string and check if it exists in the second string. If it does, increment the count of common characters. Finally, return the count of common characters. The function should be named num_common_chars and should accept two parameters: str1 and str2.
  
  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("abc", "def")==0
  assert num_common_chars("aaa", "a")==1
  assert num_common_chars("programming", "language")==4
  assert num_common_chars("", "")==0
output: def num_common_chars(str1, str2):
      common = 0
      for c in str1:
          if c in str2:
              common += 1
      return common