IDE

Input and output files

Programs that work with files need real files. Two locations do that, and they are not the same as your project's source files.

Path What it holds Written by
/uploads Files you upload for the program to read You
/myfiles Files the program writes, for you to download Your program

Your project's own source files are separate from both. These two are the program's data, not its code.

Uploading input files

Open the Input Files panel, then drag files in or browse for them. They upload straight away and are then at /uploads/<name>, which is the path your program opens.

with open('/uploads/input.txt') as f:
    print(f.read())

Downloading what the program wrote

Write to /myfiles and the file appears in the Generated Files panel after the run, where you can download it.

with open('/myfiles/result.txt', 'w') as f:
    f.write('done\n')

Until a run produces something, that panel says there are no files generated.

Why this matters for teaching

An exercise that reads a real input file and produces a real output file is a truer test than one that reads a hard-coded string. It is also how assessment questions with file input are set.

What next

The AI assistant sits beside the editor and can see the code you are working on.

This website uses cookies to ensure you get the best experience on our website.