def GetProblemIndexFromKey(problems, problem_key):
  """Get a problem's index given its key and a problem list.

  Args:
    problems: Iterable of problems in the current contest.
    problem_key: String with the problem key that must be searched.

  Returns:
    The index of the requested problem in the problem list. If the problem is
    not found this method returns None.
  """
  # Look at all the problems and return position of the first problem whose
  # key matches the looked key.
  for i, problem in enumerate(problems):
    if problem['key'] == problem_key:
      return i
  return None