python - Key error in dna complement -
python - Key error in dna complement - import string import os,sys file=open("c:\python27\\new text document.txt",'r')\ seq =file.readlines() basecomplement = {'a': 't', 'c': 'g', 'g': 'c', 't': 'a'} def translate(seq): aaseq = [] str in seq: aaseq.append(basecomplement[str]) homecoming aaseq frame in range(1): rseqn= (''.join(item.split('|')[0] item in translate(seq[frame:]))) rseqn = rseqn[::-1] print(rseqn) print(seq) error here file "c:\users\ram\desktop\pythonhw\dnacomp.py", line 13, in <module> rseqn= (''.join(item.split('|')[0] item in translate(seq[frame:]))) file "c:\users\ram\desktop\pythonhw\dnacomp.py", line 10, in translate aaseq.append(basecomplement[str]) keyerror: 'agtctggcataccagtacagactatca' if utilize simple string getting sequence tried read file input shows next err...