我是第一次使用python和使用python函數功能的新手。我已經寫THR像代碼:如何將任何函數參數附加到Python中的輸出列表
def chunks(l, n):
for i in range(0, len(l), n):
chunk = l[i:i+n]
G = chunk.count('G')
C = chunk.count('C')
A = chunk.count('A')
T = chunk.count('T')
G_C = G+C
Total_G_C_A_T = G_C+A+T
G_C_contents = ((G_C)/float(Total_G_C_A_T))*100
GC_Window100.append(G_C_contents)
print (GC_Window100)
chunks (list3, 100)
chunks (list3, 150)
chunks (list3, 200)
我的問題是:如何我可以列表爲計算附加n的值?就像我正在使用GC_Window100一樣,我希望100應該來自函數參數,以便我可以跟蹤列表,來自哪個塊。我需要多次重複這個功能。 和輸出欲想:
GC_Window100 = [30,32,31,42]
GC_Window150 = [18,20,22,20]
GC_Window200 = [15,13,16, 10] 。 。 。
任何幫助?提前致謝。
你想N的遞增的循環?或者你想在for循環中使用它嗎? – jramirez