You are viewing a single comment's thread. Return to all comments →
You can also do (Counter(s1) - Counter(s2)).values() to get the list of counts outright. Not a big difference but at least you can skip the step of converting to a list :)
Yep. A simple
print(sum((Counter(s[:l//2]) - Counter(s[l//2:])).values()))
works (after checking the length is even of course). No loop!