Created
August 27, 2021 15:21
-
-
Save marcosan93/42abf2efc9d4325eb05cde7893374db8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def emailGen(name, duplicateFound=False): | |
| """ | |
| Generates a random email address based on the given name. | |
| Adds a number at the end if a duplicate address was found. | |
| """ | |
| # Fake domain name to use | |
| dom = "@fakemail.com" | |
| # Lowercasing and splitting | |
| name = name.lower().split(" ") | |
| # Random character to insert in the name | |
| chars = [".", "_"] | |
| new_name = name[0] + random.choice(chars) + name[1] | |
| # Further distinguishing the email if a duplicate was found | |
| if duplicateFound: | |
| # Random number to insert at the end | |
| num = random.randint(0,100) | |
| # Inserting at the end | |
| new_name = new_name + str(num) | |
| # Returning the email address with the domain name attached | |
| return new_name + dom |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment