You can download this code by clicking the button below.
This code is now available for download.
This function takes a username and a domain (default to 'example.com') and generates a random email address. The random part is composed of lowercase letters.
Technology Stack : random, string
Code Type : Python Function
Code Difficulty : Intermediate
def get_random_user_email(username, domain='example.com'):
import random
import string
# Generate a random email address
characters = string.ascii_lowercase
email = f"{username}@{domain}"
return ''.join(random.choice(characters) for i in range(5)) + email