Distinct songs per artist

Write codeMedium15 min

Your task

A streaming service logs each play as a single string "artist:song", the artist name, a colon, then the song title (neither part contains a colon, both are non-empty). The same song can be played many times. From a list of such entries, compute for each artist how many distinct songs of theirs were played, and return a dictionary mapping artist to that distinct-song count. For example, ["ada:one", "ada:two", "bea:one", "ada:one"] returns {"ada": 2, "bea": 1}, note the repeated "ada:one" does not raise ada’s count.

Examples

songs_per_artist(plays: list[str]) -> dict[str,int]
Example 1
Inputsongs_per_artist(["ada:one", "ada:two", "bea:one", "ada:one"])
Output{"ada": 2, "bea": 1}