I have a program and reads from a .txt file that I have created using another python code. I'm having trouble finishing this one.
It needs to read the .txt and spit out the numbers in that file along with their sum. Here's what I've got so far:
def main():
total = 0
myfile = open('numbers.txt', 'r')
for line in myfile:
amount = float(line)
total += amount
print('End of file')
print('Numbers in file add up to ', format(total, ',.1f'), end='')
myfile.close()
main()
I get the error msg:
ValueError: could not convert string to float: '11 13 11 7 7'
print('Numbers in file add up to ', format(total, ',.1f'), end=' ')? (see that space)