"davidj411" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] |i am parsing a cell phone bill to get a list of all numbers and the | total talktime spend on each number. | | i already have a unique list of the phone numbers. | now i must go through the list of numbers and add up the totals for | each number.
| here is the function i wrote to get one number at a time's total | talktime. | | def getsinglenumbertalktime(number,talktime): | for line in file[0:-2]: ... | | talktime = talktime + li[5] | return talktime It would appear that you are calling this function and rescanning scanning file for each number. It would be more efficient to scan the file once, for each line parsing out the number and minutes and incrementing the minutes for that number. Also, if you had printed repr(li[5]) and len(li[5]) instead of or in addition to just li[5] (which prints str(li[5]), >>> a='"2"' >>> print a, repr(a), len(a) "2" '"2"' 3 you might have seen for yourself the problem that the string contains quote marks and not just digits. Repr and len are useful debugging aids. tjr -- http://mail.python.org/mailman/listinfo/python-list