Typescript Count Elements In Array Python Question