On 6 Sep, 09:00, Maggie <la.f...@gmail.com> wrote: > code practice: > > test = open ("test.txt", "r") > readData = test.readlines() > #set up a sum > sum = 0; > for item in readData: > sum += int(item) > print sum > > test file looks something like this: > > 34 > 23 > 124 > 432 > 12 >
>>> sum(map(int, open('test.txt', 'r'))) Assuming the test file looks like above, and isn't stored in rtf format or something like that. (Open the test file in the python editor to check its contents). /Niklas -- http://mail.python.org/mailman/listinfo/python-list