input: from typing import List, Dict
  
  def list_to_dict(names_and_ages: List[str]) -> Dict[str, int]:
      """ Converts a list of strings where each string is a name followed by an age
      enclosed in parentheses, into a dictionary where the names are keys and the
      ages are values.
      >>> list_to_dict(['John (20)', 'Jane (40)', 'Alex (18)', 'Peter (45)'])
      {'John': 20, 'Jane': 40, 'Alex': 18, 'Peter': 45}
      """
output:     result = {}
      for item in names_and_ages:
          name, age = item.split(' (')
          age = int(age.rstrip(')'))
          result[name] = age
      return result