evidence_locker
Rīgas 64. vidusskola
Mission 8 · files

HQ seized a USB stick.
Make it talk.

A server log, two intercepted messages and a scoreboard, all plain text files. Your programs read them line by line, find the intruder, crack the code, and write their own files back.

evidence-locker.zip 12 files

> boot sequence

  1. Download

    Click the green button. The zip lands in Downloads.

  2. Extract

    Right-click the zip → Extract All… Don't work inside the zip!

  3. Open folder

    VS Code → File → Open Folder… → pick the evidence-locker folder. The .txt files must be in the list on the left.

  4. Open a file

    Click welcome.txt to see a file, then 00_open.py.

  5. Run ▶

    The triangle in the top right. Your program talks to you in the terminal at the bottom.

> files

> cheat sheet

with open("x.txt", encoding="utf-8") as f:open a file to read. It closes by itself at the end of the block
f.read()the whole file as one string
for line in f:one line at a time
line.strip()cut off the invisible "\n" at the end
line.split(",")"viper,Kai,5" → ["viper", "Kai", "5"]
int(parts[2])files only hold text. Make it a number
open("x.txt", "w", …)write a new file. Wipes the old one!
open("x.txt", "a", …)append: add to the end, nothing lost
f.write(text + "\n")write text. You add the new line yourself
f.write(str(41) + "\n")numbers must become text first

> something broke

FileNotFoundError

Python can't find the file. Did you extract the zip (not just open it)? Is the .txt file in the list on the left, in the same folder as your .py? Is the name spelled right, with .txt?

Weird letters like Ä« instead of ī

You forgot encoding="utf-8" in open(…). Write it every time.

TypeError: can only concatenate str (not "int")

Everything from a file is text. "5" + 1 fails. Use int(…) to read a number and str(…) to write one.

IndexError: list index out of range

A line didn't have enough commas, usually an empty line at the end of the file. Add if line.strip() == "": continue at the top of the loop, or delete the empty line.

My file is empty / my old data is gone

"w" wipes the file the moment it opens. Use "a" to add to the end. Lost the original? Extract the zip again.

I wrote to the file but nothing changed

Check you ran the program (▶). Then click the file again on the left, or close and reopen its tab.

A red error in the terminal

Read the last line first: it says what went wrong. The line above it says which line of your file. Ctrl+click the file name to jump there.