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
Exercise instructions
- Define a function called
generate_emailthat takes one argument calledfull_name. - Return the generated
emailfrom the function. - Call the function on the
full_namestring.
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(____(____))