I'm having some trouble with the problem, the instruction states to create another file that had the following text, which I did using Python IDLE which then I saved. But I do not understand what I did wrong since it states the file does not exist/work. I am requesting a video on how to solve this problem and also accepts a file name as a parameter and where to save as well.
Write a function called boy_girl that accepts a file name as a parameter. Your function should read input from that file containing a series of names followed by integers. The names alternate between boys’ names and girls’ names. Your function should compute the absolute difference between the sum of the boys’ integers and the sum of the girls’ integers. The input could end with either a boy or a girl; you may not assume that it contains an even number of names. For example, if the input file contains the following text::
Dan 3
Cordelia 7
Tanner 14
Mellany 13
Curtis 4
Amy 12
Nick 6
Then the function should produce the following console output since the boys’ sum is 27 and the girls’ sum is 32:
4 boys, 3 girls
Difference between boys' and girls' sums: 5
Michael D.
07/28/24