June 2021
Beginner
208 pages
3h 50m
English
Python makes it easy for your programs to use files and connect to the Internet. You can read data from files, write data to files, and fetch content from the Internet. You can even check for new mail and tweet—all from your program.
When you run a Python program, any values you have in variables will be lost. Files provide a means of making data more permanent.
Python makes reading the contents of a file extremely easy. As an example, we can convert the Hangman program from Chapter 4 to read the list of words from a file rather than have them fixed in the program.
First of all, start a new file in Mu and put some words in it, one per line. Then save the file with the name hangman_words.txt in the ...