Your question is Top Five Error Codes. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a list of log lines logs, write a function that extracts error codes and returns the five most frequent ones. An error code appears only in lines containing the token ERROR and is the first alphanumeric token immediately following ERROR. Return a list of [code, count] pairs sorted by descending frequency, and for ties sort lexicographically by code.
ERRORdef top_five_error_codes(logs):