aa_mass = { 'A': 71.03711, 'G': 57.02146, 'M': 131.04049, 'S': 87.03203, 'C': 103.00919, 'H': 137.05891, 'N': 114.04293, 'T': 101.04768, 'D': 115.02694, 'I': 113.08406, 'P': 97.05276, 'V': 99.06841, 'E': 129.04259, 'K': 128.09496, 'Q': 128.05858, 'W': 186.07931, 'F': 147.06841, 'L': 113.08406, 'R': 156.10111, 'Y': 163.06333 } gen_id = input('Enter gen ID:') sequence = input('Enter amino acid sewuence:') mass=sum(aa_mass.get(aa.upper(), 0) for aa in sequence) print(f"Protein {gen_id} has a mass of {mass:.2f} Da.") # better use f-stringif you prefer ordinary loop instead of list comprehension
mass = 0 for aa in sequence: mass += aa_mass.get(aa.upper(), 0)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs