gpt4 book ai didi

python - 谁能帮我找出这段代码有什么问题吗?相同RNA序列匹配程序

转载 作者:太空宇宙 更新时间:2023-11-03 18:44:50 24 4
gpt4 key购买 nike

这是我到目前为止所得到的:提示用户输入两个序列时似乎存在错误。

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 问题。此外,herestr.split 的文档。)

关于python - 谁能帮我找出这段代码有什么问题吗?相同RNA序列匹配程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19754520/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com