to sum a list in a dictonary
Beema shafreen
beema.shafreen at gmail.com
Thu Nov 1 10:54:30 EDT 2007
hi everybody,
I need to sum a list in dictionary...
my script,
d = {}
probes = list(enumerate((i.split('\t')[2],i.split('\t')[3],
i.split('\t')[4])for
i in open('final_lenght_probe_span')))
for idx, (probe_id, span, length) in probes:
try :
l = [span,length.strip(),probes[idx+1][1][1]]
d[probe_id] = sum[l]
except IndexError :
none = 0
l = [span,length,None]
d[probe_id] = sum[l]
for key in d.keys():
print key, d[key]
I used an built-in fuction sum to add the list, but is results in error...
now how do i do it
my file used is:
2709852 2709911 A_16_P21360207 405 -59
2710316 2710367 A_14_P136880 -42 -51
2710325 2710384 A_16_P21360209 876 -59
2711260 2711319 A_16_P21360210 -22 -59
2711297 2711356 A_16_P03641959 254 -59
2711610 2711659 A_16_P03641960 982 -49
2712641 2712696 A_16_P03641962 1011 -55
2713707 2713765 A_16_P41563648 43 -58
2713808 2713861 A_16_P03641963 -16 -53
2713845 2713893 A_16_P41563649 3460 -48
2717353 2717412 A_16_P03641964 214 -59
2717626 2717685 A_16_P41563655 25 -59
2717710 2717754 A_16_P03641965 1250 -44
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071101/cd98889c/attachment.html>
More information about the Python-list
mailing list