Editor

Build a String with reduce

Advanced · Write the code · from Python functools: lru_cache, partial, reduce, singledispatch

From the lesson: Python functools: lru_cache, partial, reduce, singledispatch

Imagine your functions could remember past answers, come pre-loaded with some arguments, or automatically handle different data types. That's what the functools module gives you: power-ups for your functions.

Read the lesson

Use reduce to join the list ['Python', 'is', 'awesome'] into a single string with spaces between words. Use a lambda that concatenates two strings with a space. Print the result.

from functools import reduce
words = ['Python', 'is', 'awesome']
# Use reduce to join words with spaces

More functools exercises

All Python exercises · 50 practice problems · Standard Library Essentials quiz