CommencerCommencer gratuitement

The reduce() function

Now, it is time for some reduction! As before you'll be given three tasks to complete. Use lambda expressions!

The necessary functions from the functools module are already imported for you.

Cet exercice fait partie du cours

Practicing Coding Interview Questions in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Reverse a string using reduce()
string = 'DataCamp'
inv_string = reduce(____)
print('Inverted string = ' + inv_string)
Modifier et exécuter le code