We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Welcome to Functional Programming

Functional programming is a style (or "paradigm" if you're pretentious) where we compose functions instead of mutating state. By contrast, imperative programming updates state along the way:

car = create_car()
car.add_gas(10)
print(car.get_gas())
# 10

Functional programming composes functions that return new values:

car = create_car()
car_with_gas = add_gas(car, 10)
gas = get_gas(car_with_gas)
print(gas)
# 10

Each function's output becomes the next function's input. The original car isn't changed, because add_gas just returns a new copy.

Assignment

In this course, we're working on Doc2Doc, a command line tool for converting documents from one format to another (like Pandoc)... but there's a problem with the stylize_title function.

Before returning the document with the border, call center_title and pass it the document, capturing its return value in the centered_doc variable.