getting all of the currecny values out of a text file
<p>im having trouble with getting my python code to read through a text file and add together all of the monetary values. the code seemed to be working fine on my pc, but as soon as i transferred the file to my mac it gave me a whole slew of errors. here is the code</p>

<pre><code>#!usr/bin/python
import sys

def findnum(x):
    list = x.split(' ')
    index = 0
    listindex = -1
    numlist = []
    sum = 0

    for w in list:
        if ((w.strip('. n,')).isalpha() != True and w[0].isalpha() != True and w[-2].isdigit() == True):
            numlist.append(w)
            listindex += 1

    while listindex &gt;= 0:
        sum += float(numlist[listindex].strip('$ n.'))
        listindex -= 1
    return sum
def main():
    text = open(sys.argv[1])
    x = text.readline()
    sum = 0
    if len(x) &gt; 0:
        findnum(x)
        while len(x) &gt; 0:
            sum += findnum(x)
            x = text.readline()
    print '{0:.2f}'.format(sum)

if __name__ == '__main__':
    main() 
</code></pre>

<p>here is the text
This is your invoice from the ACME materials
company.  You received 50lbs of sand at a
cost of $40.  The brick we delivered is 70.5
for the 75Kg.  In addition, we delivered 30yards
of sod for $200.00.  Delivery charge is $35.</p>

<p>so i need to add 40 + 70.5 + 200 +35
i keep getting a index out of range error..
anyone think they can help me out?</p>
