You are a biologist working on the amino acid  composition of proteins. Every protein consists of a long chain of 20 different amino acids with different properties. 
Currently, you are collecting data on the percentage, various amino acids make up a protein you are working on. As manually counting the occurences of amino acids takes too long (especially when counting more than one amino acid), you decide to write a program for this task:

Write a function that takes two arguments,
 1. A (snippet of a) protein sequence
 2. A list of amino acid residue codes 

and returns the rounded percentage of the protein that the given amino acids make up. 
If no amino acid list is given, return the percentage of hydrophobic amino acid residues ["A", "I", "L", "M", "F", "W", "Y", "V"].

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def aa_percentage(seq, residues=["A", "I", "L", "M", "F", "W", "Y", "V"]):
	

Solutions:
def aa_percentage(seq, residues=['A', 'I', 'L', 'M', 'F', 'W', 'Y', 'V']):
	return round(sum((seq.count(r) for r in residues)) / len(seq) * 100)


def aa_percentage(seq, acid='AILMFWYV'):
	return round(sum((x in acid for x in seq)) * 100 / len(seq))


def aa_percentage(protein, residue='AILMFWYV'):
	return round(100 * sum((protein.count(aa) for aa in set(residue))) / len(protein))


def aa_percentage(seq, targets=['A', 'I', 'L', 'M', 'F', 'W', 'Y', 'V']):
	return round(sum([seq.count(ch) for ch in targets]) / len(seq) * 100)


def aa_percentage(seq, codes=['A', 'I', 'L', 'M', 'F', 'W', 'Y', 'V']):
	return round(100 * len([x for x in seq if x in codes]) / len(seq))


def aa_percentage(prot, rsd='AILMFWYV'):
	rsd = set(rsd)
	return round(sum((p in rsd for p in prot)) / len(prot) * 100)


def aa_percentage(*prot):
	if len(prot) > 1:
		sear = prot[1]
	else:
		sear = ['A', 'I', 'L', 'M', 'F', 'W', 'Y', 'V']
	times = 0
	for i in sear:
		times += prot[0].count(i)
	return round(times / len(prot[0]) * 100)


def aa_percentage(seq, codes='AILMFWYV'):
	codes = set(codes)
	return round(sum((c in codes for c in seq)) / len(seq) * 100)


def aa_percentage(sequence, list=['A', 'I', 'L', 'M', 'F', 'W', 'Y', 'V']):
	counts = [sequence.count(x) for x in list]
	return round(sum(counts) * 100 / len(sequence), 0)


def aa_percentage(s, a=None):
	print(repr(a))
	return round(100 * sum((i in ('AILMFWYV' if a is None else a) for i in s)) / len(s))