You’re already familiar with the print(), input(), and len() functions from the previous chapters. Python provides several built-in functions like these, but you can also write your own functions. A function is like a miniprogram within a program.

To better understand how functions work, let’s create one. Enter this program into the file editor and save it as helloFunc.py:

def hello():      print('Howdy!')        print('Howdy!!!')        print('Hello there.') hello()    hello()    hello()

You can view the execution of this program at https://autbor.com/hellofunc/. The first line is a def statement , which defines a function named ...

Get Automate the Boring Stuff with Python, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.