题解 | #DNA序列#
DNA序列
https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a
def GC_Ratio(s): G_n = s.count('G') C_n = s.count('C') Ratio = (G_n+C_n)/Length s_L.append(s) Ration_L.append(Ratio) DNA = input() Length = int(input()) s_L = [] Ration_L = [] for i in range(len(DNA)-Length+1): GC_Ratio(DNA[i:i+Length]) print(s_L[Ration_L.index(max(Ration_L))])