Anthony B. answered 10/16/23
Software Engineer, Python/Java/Javascript with AI Background
Breaking the assignment into basic steps:
- Read the lines of the file into a list
- Read the first line to determine which column holds which data
- convert the current line's albumid and trackid to integers
- Check to see which ids are even/odd using the modulo operator (%)
- If both are even, write the original line to the even track file
- Else if both are odd, write to the odd track file
- Instructions unclear whether to write to separate neither file or just ignore lines that have a mix of both.
- Go back to step 3 and loop until all lines are read
Note:
In the instructions, it mentions:
When writing the open statement for both files add this to the statement(see in red)
open("Name of your file", "r", encoding="utf8")
However it should be using "w" when writing as it would have insufficient permissions to write otherwise. So should be something like:
open("Name of your file", "w", encoding="utf8")