from collections import Counterdef anagram(first, second): return Counter(first) == Counter(second)anagram("abcd3", "3acdb") # True