Python
(0%)
(0%)

Sign In Sign Up
1/9
File Input/Output
See It to Believe It

Until now, the Python code you've been writing comes from one source and only goes to one place: you type it in at the keyboard and its results are displayed in the console. But what if you want to read information from a file on your computer, and/or write that information to another file?

This process is called file I/O (the "I/O" stands for "input/output"), and Python has a number of built-in functions that handle this for you.

Check out the code in the editor to the right. Note that you now have an extra output.txt tab, which is just an empty text file. That's all about to change!

Instructions

Click Save & Submit Code, then check out the output.txt tab to see Python's file I/O powers in action.

script.py
output.txt
Back to Editor

Sign in