Learn
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.

Instructions

1.

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

Folder Icon

Take this course for free

Already have an account?