Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Python by (120 points)

Write a function sum_col(f) that takes a filename f. Each line in f contains three comma-separated numbers. You should write at the end of the file the sum of the odd rows of each column in the file.

 Example file ('example.txt'): 

1,2,3 

4,5,6 

-1,2,0

 10,20,13 

5,3,4 

For the following function call Sum_col('example.txt') the 'example.txt' file will be updated to the following: 1,2,3

 4,5,6 

-1,2,0

 10,20,13

 5,3,4

 Totals:

 5,7,7 

Please log in or register to answer this question.

Browse Categories

...