ComeçarComece de graça

Lambda functions with iterables

You've used lambda functions on single values - now let's apply them to entire lists! This is where lambda functions really shine: when you need the same operation on every item.

In this task, you'll process a list of colleague names using a lambda function applied to the entire list.

Este exercício faz parte do curso

Python intermediário para desenvolvedores

Ver curso

Instruções do exercício

  • Apply the lambda function to each value in the colleagues list, saving as cleaned.
  • Convert the map object to a list, saving as cleaned_list.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

colleagues = ["Sarah Martinez", "Michael Chen", "Emily Brown"]

# Apply the lambda function to each colleague's name
cleaned = ____(lambda x: x.replace(" ", "_").lower(), ____)

# Convert map object to list
cleaned_list = ____(____)
print(cleaned_list)
Editar e executar o código