I am a biology graduate student and I taught myself a very limited amount of python in the past few months to deal with some data I have. I am not asking for homework help, this
Your problem stems from the line
if cds[n:n+3] in codontable == True
This always evaluates to False
, and thus you never append to proteinsequence
. Just remove the == True
portion like so
if cds[n:n+3] in codontable
and you will get the protein sequence. Also, make sure to return proteinsequence
in translate_dna()
.