Aug-25-2019, 08:51 AM
You are overwriting weight for each aa in the input and calculating the sum of an int
so either:
so either:
prot_weight = {'A':89, 'V':117, 'L':131, 'I':131, 'P':115, 'F':165, 'W':204, 'M':149, 'G':75, 'S':105, 'C':121, 'T':119, 'Y':181, 'N':132, 'Q':146, 'D':133, 'E':147, 'K':146, 'R':174, 'H':155} prot_sequence = input('please write the amino acid sequence = ') weight = 0 for aa in prot_sequence: weight += prot_weight[aa] print(weight)or do it the pythonic way:
prot_weight = {'A':89, 'V':117, 'L':131, 'I':131, 'P':115, 'F':165, 'W':204, 'M':149, 'G':75, 'S':105, 'C':121, 'T':119, 'Y':181, 'N':132, 'Q':146, 'D':133, 'E':147, 'K':146, 'R':174, 'H':155} prot_sequence = input('please write the amino acid sequence = ') weight = sum(prot_weight[character] for character in prot_sequence) print(weight)