askGene=input("Enter Gene:")
ans=askGene.upper()
print(ans)
newStr=''
start=0
end=0
newList=[]
for i in askGene:
new=ans[start:end]
newList.append(new)
start+=3
end+=3
print(newList)
答案 0 :(得分:0)
使用列表理解:
askGene = "ABCDEFGHIJKLMNOPQR"
newList = [askGene[i:i+3] for i in range(0, len(askGene), 3)]
这给出了输出:
['ABC', 'DEF', 'GHI', 'JKL', 'MNO', 'PQR']