beginner's python help

Maggie la.foma at
Sun Sep 6 09:00:16 CEST 2009

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:


when i am trying to compile this it gives me the error: invalid
literal for int() with base 10

i know a lot of people get this and it usually means that you try to
cast a string into an integer and this string does not really contain
a “digit” I am just not sure how to correct it in this case...

thanks for your input

More information about the Python-list mailing list