为了得到输入字符的补码,下面的代码怎么不能工作?似乎循环永远不会结束,但是假设我输入“Z”作为 dna,为什么它不会中断并退出?我是否使用了休息或错误?艾利夫呢?
def get_complement(dna):
''' (ch) -> ch
Reverse the 'A' to 'T' or vice versa and 'C' to 'G' and vice versa too.
>>> get_complement('A')
'C'
>>> get_complement('G')
'T'
'''
if dna == 'A':
print ('C')
if dna == 'C':
print ('A')
if dna == 'T':
print ('G')
if dna == 'G' :
print ('T')
while {'A', 'C', 'G', 'T'}.isnotsubset(set(dna)) :
break
return ('')