<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def format_from_extension(self, extension):
 """Find a format from its extension."""

        formats = [name
                   for name, format in self._formats.items()
                   if format.get('file_extension', None) == extension]
        if len(formats) == 0:
            return None
        elif len(formats) == 2:
            raise RuntimeError("Several extensions are registered with "
                               "that extension; please specify the format "
                               "explicitly.")
        else:
            return formats[0]