0

Do handling Corrupt lines by prepending "corrupt" as the result #Other lines should be handled correctly

#3::::5 => corrupt:3::::5

3 5:1 2 3 4 5 6 7 8 9 Hello World => corrupt:3 5:1 2 3 4 5 6 7 8 9 Hello World

def f10(inFile, outFile):
    try:
        with open(outFile, "w") as op_file:
            for line in open(inFile):
                val = sum_of_factors(
                    *[[int(x) for x in y.split(" ")] for y in line.rstrip().split(":")]
                )
                print(val)
        op_file.write(str(val) + ":" + line.strip() + "\n")
        op_file.close()
    except FileNotFoundError:
        print("Error: Input file not found.")
    except IOError as e:
        print(f"Error: An IO error occurred - {e}")

f10("./input", "./output")

2
  • 1
    Please format your code/question appropriately because it's not readable currently. Commented Oct 9, 2023 at 12:02
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Oct 9, 2023 at 13:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.