图一是我对于这道题写的代码
检查时候发现我遗漏了图二题目中标黄的要求
请问如何修改这段代码才可以完善?
初学者求帮助,谢谢
gene_str = input("请输入基因组字符串:")
# gene_str = "TTATGTTTTAAGGATGGGGCGTTAGTT"
end_str = ["TAG","TAA","TGA"]
exclude_str = ["ATG","TAG","TAA","TGA"]
n = len(gene_str)
res = list()
i = 0
while i < n:
if gene_str[i:i+3] == "ATG":
start = i+3
while i < n:
i += 3
if gene_str[i:i+3] in end_str:
res.append(gene_str[start:i])
i += 3
break
if gene_str[i:i+3] in exclude_str:
break
else:
i += 1
if res:
print(*res, sep="\n")
else:
print("No gene is found.")
chatroom_friends = getChatroomFriends(chatrooms, friend_overlap)
#% 置换username为名称
result_chatroom_friends = copy.deepcopy(chatroom_friends)
for k in result_chatroom_friends:
usernames = result_chatroom_friends[k]['friends']
result_chatroom_friends[k]['friends'] = ' | '.join(friend_overlap.loc[usernames]['RemarkName'].tolist())
result_chatroom_friends = pd.DataFrame(result_chatroom_friends).T
result_chatroom_friends = result_chatroom_friends[['total', 'num', 'friends']]
# 数据用完,处理friend_overlap
friend_overlap = getSameChatroomInfo(chatroom_friends, friend_overlap)