input: Write a function that takes two strings and returns whether they are anagrams. The function should check if the two strings have the same characters with the same frequencies. If they do, the function should return True; otherwise, it should return False.
  
  def is_anagram(str1, str2):
      if len(str1) != len(str2):
          return False
  
      str1_counts = collections.Counter(str1)
      str2_counts = collections.Counter(str2)
      
      for char in str1_counts:
          if str1_counts[char] != str2_counts[char]:
              return False
      return True
  
  assert is_anagram("abcd", "cbda")==True
  assert is_anagram("hello", "world")==False
  assert is_anagram("silent", "listen")==True
  assert is_anagram("debit card", "bad credit")==True
  assert is_anagram("cat", "dog")==False
output: def is_anagram(str1, str2):
      if len(str1) != len(str2):
          return False
  
      str1_counts = collections.Counter(str1)
      str2_counts = collections.Counter(str2)
      
      for char in str1_counts:
          if str1_counts[char] != str2_counts[char]:
              return False
      return True