Binary Files · 8 / 14 Exercise Medium

Inverted file

Objective

Create a program in Python that inverts all the bytes of a binary file. Open the files in binary mode (rb and wb). You must create a new file with the same name but with the extension .inv.

Files: the file data.bin already exists. Create the file data.inv with all the bytes of data.bin in reverse order (the last byte first). Use binary mode. The program must not print anything.

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise