input1 = input("Corrupted: ")
input2 = ""
final = ""
for i in input1:
if i in "ATGC ":
input2 = input2 + i
for i in set(input2.split()):
final = final + i + " "
print("DNA:",final.rstrip())
该程序的目的是允许用户输入一串文本,其中隐藏着一个 DNA 代码。该程序提取 DNA 代码(基本上是任何不是 ATCG 的代码)。它还删除了重复的整体。它做的一切都是正确的,但它以错误的顺序打印出问题。我会向我的导师寻求帮助,但他目前无法帮助我。
Corrupted: A1TGcC A?T-G %^AT@CT ATGc #Notice the double ATG (2nd and last one)
DNA: ATGC ATCT ATG #Only one ATG since one is removed.
当它打算输出时:
Corrupted: A1TGcC A?T-G %^AT@CT ATGc #This one is in the correct order. How do I get it to stay in the same order?
DNA: ATGC ATG ATCT