I am new to coding and am trying to make a function that will add the numbers given in a file. I have a solution that gives me the sum of the numbers but there is a "None" value being returned as well. How do I stop this from happening? My code looks like this
def addIntegersFromFile(file):
newfile = file
total = 0
with open(newfile, 'r') as numbers:
number = numbers.read()
list1 = number.strip("\n")
list2 = list1.split("\n")
for value in list2:
total += float(value)
print(total)
It will return the sum of a file and then a new line with a "None" value.
Ex:
6.0
None