Get startedGet started for free

Custom function syntax

As part of the IT support team, you frequently need to convert employee names into their company email addresses. The company follows a standard email format: first name (lowercase) + dot + last name (lowercase) + @techcompany.com. For example, "Jane Doe" becomes [email protected].

Instead of manually creating these emails repeatedly, you'll build a custom function to automate this task.

This exercise is part of the course

Intermediate Python for Developers

View Course

Exercise instructions

  • Define a function called generate_email that takes one argument called full_name.
  • Return the generated email from the function.
  • Call the function on the full_name string.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

full_name = "Alan Turing"

# Define the generate_email function
____ ____(full_name):
    name_parts = full_name.split()
    email = name_parts[0].lower() + '.' + name_parts[1].lower() + '@techcompany.com'
    
    # Return the email address
    ____ ____

# Call the function on the full_name string
print(____(____))
Edit and Run Code