Counting country ids from a list

Question

Suppose you're given the list of ids along with the associated country in the suffix:

  • asdfkji882-US
  • asldfff12-US
  • masnfnasdff12-US
  • yyourwekks112-CH
  • uuiiudsf-CH
  • lkjasfe2-FR
  • iieuujdjk-GM

Given this list, write a function to count the number of ids we have per country. Output should be: {'CH': 2, 'FR': 1, 'GM': 1, 'US': 3}

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now