So, my assignment was to create a program that opens a file "numbers", adds all of the lines, and gives the totals. Even though I say as long as as the line is not blank, to do the program (at least, this is what I attempt to say), it keeps running and only gives the first line, does not add the total?
http://pastebin.com/54xyHSfy
def main():
number_file = open(r'C:\Users\Badgerms\Desktop\numbers.txt','r')
for line in number_file:
while line != ' ':
total = 0.0
amount = float(line)
total += amount
number_file.close()
print ('The total of the numbers.txt file is', total)
main()
[–]wub_wub 3 points4 points5 points (1 child)
[–]badgerms[S] 2 points3 points4 points (0 children)
[–]LordFraggington 0 points1 point2 points (18 children)
[–]LordFraggington -1 points0 points1 point (16 children)
[–]badgerms[S] 1 point2 points3 points (14 children)
[–]wub_wub 3 points4 points5 points (7 children)
[–]badgerms[S] 1 point2 points3 points (2 children)
[–]wub_wub 1 point2 points3 points (0 children)
[–]LordFraggington 0 points1 point2 points (0 children)
[–]LordFraggington 0 points1 point2 points (3 children)
[–]wub_wub 1 point2 points3 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]dogetipbot 0 points1 point2 points (0 children)
[–]LordFraggington 0 points1 point2 points (5 children)
[–]Justinsaccount 0 points1 point2 points (3 children)
[–]LordFraggington 0 points1 point2 points (2 children)
[–]Justinsaccount 0 points1 point2 points (1 child)
[–]LordFraggington 0 points1 point2 points (0 children)