I have a file I'm working with that has an integer per line and no commas are separating the numbers. When I go to get the sum of the numbers in that file, it only works for positive integers. What I have doesn't work for negative numbers in the file. Any way of being able to accomplish that? My code in question:
if line.strip().isdigit():
total += int( line)
If all the numbers in the file are negative, it'll just return the sum as 0. What other method of achieving the same goal (sum of all numbers in file) could I use that would work to add positive and negative integers?