这是我到目前为止所得到的:提示用户输入两个序列时似乎存在错误。
def matchSequences(sequence1, sequence2):
numMatches = 0
(input("Enter the RNA sequences")==(sequence1, sequence2)
for i in range(0,len(sequence1))
if sequence1[i] == A and i in sequence2[i] == U
numMatches = numMatches+1
if sequence1[i] == C and i in sequence2[i] == G
numMatches = numMatches+1
if sequence1[i] == G and i in sequence2[i] == C
numMatches = numMatches+1
if sequence1[i] == U and i in sequence2[i] == A
numMatches = numMatches+1
elif numMatches == numMatches+0:
for i in range (sequence1, sequence2)
if i in sequence1[i]:
numMatches == numMatches+1
elif numMatches == numMatches+0:
return numMatches
matchSequences()
在我看来,你应该有这样的东西,而不是(input("输入RNA序列")==(sequence1,sequence2)
:
sequence1, sequence2 = input("Enter the RNA sequences, seperated by a comma: ").split(",")
在这种情况下,您不需要函数有参数,只需执行 def matchSequences()
即可。
如果您想要使用参数,请删除包含输入的行,保留原始的def matchSequences(sequence1,sequence2)
,而不是仅仅这样做:
matchSequences()
这样做:
first_sequence = input("Enter the first sequence: ")
second_sequence = input("Enter the second sequence: ")
matchSequences(first_sequence, second_sequence)
或者这个:
matchSequences(*input("Enter the RNA sequences, seperated by a comma: ").split(","))
(有关 *
在这里做什么的问题,请参阅 this 问题。此外,here 是 str.split
的文档。)
我是一名优秀的程序员,十分优秀!