Random User Email Generator

  • Share this:

Code introduction


This function accepts two parameters, `first_name` and `last_name`, and generates a random user email address. The email address is composed of the lowercase combination of the name and surname, with the name added before the surname, followed by a random six-character suffix, and finally the specified domain.


Technology Stack : Fastify, Python built-in modules (random, string)

Code Type : Function

Code Difficulty : Intermediate


                
                    
def create_random_user_email(first_name, last_name):
    import random
    import string
    domain = "example.com"
    email_prefix = f"{first_name.lower()}.{last_name.lower()}"
    random_suffix = ''.join(random.choices(string.ascii_lowercase + string.digits, k=6))
    return f"{email_prefix}.{random_suffix}@{domain}"