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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.