5 Working with files: Being a shop manager

 

In this chapter

  • Erik learns what a coffee shop manager needs
  • Erik reads his menus from files
  • Erik writes his second Python function

“Last time, you said something about a coffee shop manager,” Erik started with his brother the next day. “Something about changing menus? I forgot.”

“Yes, I said it might be good if your coffee shop manager could change the menus without going into Python code,” Simon said.

“Yes, good idea,” Erik said. “Not everyone knows Python.”

“My idea is to create simple text files for each menu—call them drinks.txt, flavors.txt, and toppings.txt. Then your program can read from those files and create lists from the items in the files.”

“Why did you name them all with .txt at the end?” Erik asked. “Shouldn’t they be .docx so the manager could edit them in Microsoft Word?”

New things you have learned today

Code for this chapter