python - ValueError: too many values too unpack (expected 2) -
i'm trying parse dna strings.
the input.txt contains:
rosalind_6404cctgcggaagatcggcactagaatagccagaaccgtttctctgaggcttccggccttccctcccactaataattctgagg>rosalind_5959ccatcggtagcgcatccttagtccaattaagtccctatccaggcgctccgccgaaggtctatatccatttgtcagcagacacgc>rosalind_0808ccaccctcgtggtatggctaggcattcaggaaccggagaacgcttcagaccagcccggactgggaacctgcgggcagtaggtggaat
the code is:
f = open('input.txt', 'r') raw_samples = f.readlines() f.close() samples = {} cur_key = '' elem in raw_samples: if elem[0] == '>': cur_key = elem[1:].rstrip() samples[cur_key] = '' else: samples[cur_key] = samples[cur_key] + elem.rstrip() print(samples) p_id, s in samples.values(): samples[s_id] = (s.count('g') + s.count('c'))*100 print (samples)`
i keep getting error:
file "c:/python34/test.py", line 18, in <module> p_id, s in samples.values(): valueerror: many values unpack (expected 2)
i able solve problem changing for p_id, s in samples.values()
for p_id, s in samples.items()
i noticed p_id , s_id different, meant same.
Comments
Post a Comment