def find_prot2(fasta_dict, re_str): '''Search through a dictionary of fasta entries using a regular expression''' # Import re module import re # typically imported at top of module file # Create pattern object pattern = re.compile(re_str) # Create empty list to store results result_list = [] # Iterate over all keys in dictionary for key in fasta_dict.keys(): # If the pattern matches, append to result_list if pattern.match(key): result_list.append(key) return result_list