python - I need to sum numbers from a file -


I am reading numbers from a text file whose structure is two numbers per line I need to open this file, and Numbers must be added to the range of two My program is exactly the same as I want to leave it to leave negative categories. Since I need to add all the numbers, I've added +1 at the end of the maximum number for the range. However, this is where the maximum negative negative four is for example, it makes the range like -5 instead of 5 because it should be done how do I fix it? I'm thinking the best way to write results in the output file. Thank you

  def numberSum1 (): inFile = input ('Enter the name of the input file:') outFile = input ('Enter the output file name:') Open (Infile, R ' ) As file 1, open file as file2: openList = [] x = file1.readline () as file 1: n, m = x.split () (Outfile, 'w') Print (N, m) maximum (minimum, maximum) = maximum (n, m) maximum (maximum (n, m)) print (minimum (n, m)) in print (minimum) for print (max) Minimum (minimum, max TOM - 1): finalList.append (w) finalContent = sum final list) print ('from' to {}} {}} {} format (minimum, maximum, final content)) finalList = [] file1.close ) File2.close ()  

The problem is with the parameters you want to have your < Code> min and max function before you compare them to see that they are large (right now, it's wrongly thinking that "- 4" strings to ints Needed> "- 2" is larger than ). Try it instead:

x = (n, m) maxNum = max (n) for x in x: n, m = for x [s (s) for int (k) . , M)

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -