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.



Click Run! You just wrote all the contents of my_list to a text file called output.txt.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?