<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def filter_metadata(self, key):
 """ Return a list of values for the metadata key from each field of the project's metadata. Parameters key: str A known key in the metadata structure Returns ------- filtered : attribute list from each field """

        filtered = [field[key] for field in self.metadata if key in field]
        if len(filtered) == 0:
            raise KeyError("Key not found in metadata")
        return filtered