Typescript If Not Empty Python Array Count Occurrences Of Anagrams