I\'m checking if two strings a and b are permutations of each other, and I\'m wondering what the ideal way to do this is in Python. From the Zen of
a
b
from collections import defaultdict def permutation(s1,s2): h = defaultdict(int) for ch in s1: h[ch]+=1 for ch in s2: h[ch]-=1 for key in h.keys(): if h[key]!=0 or len(s1)!= len(s2): return False return True print(permutation("tictac","tactic"))