Created
April 4, 2017 16:39
-
-
Save joemarchese/11082e9dd57ab40e628d4df1a247d76b 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
| """ | |
| Name shuffler. To take the first part and second part of names | |
| and mix them up in various ways. Co-Authored by Joe and Francesca. | |
| """ | |
| from random import choice | |
| def nameshuffler(first, last): | |
| """Combines a first and last name. Checks authenticity.""" | |
| completed = False | |
| while not completed: | |
| shuffledname = first + last | |
| if shuffledname not in Real_Names: | |
| completed = True | |
| else: | |
| completed = False | |
| return shuffledname | |
| def namegenerator(): | |
| """Asks for the first part of name and assigns new name.""" | |
| completed = False | |
| first = input('What is the first part of your name?') | |
| while not completed: | |
| shuffledname = first + choice(Last_Name_Part) | |
| if shuffledname not in Real_Names: | |
| completed = True | |
| else: | |
| completed = False | |
| return shuffledname | |
| def all_shufflednames(): | |
| """Takes first part of name and returns all shuffled names possible""" | |
| first = input('What is the first part of your name?') | |
| shufflednames = [] | |
| for lastpart in Last_Name_Part: | |
| shuffledname = first + lastpart | |
| if shuffledname in Real_Names: | |
| pass | |
| else: | |
| shufflednames.append(shuffledname) | |
| return shufflednames | |
| First_Name_Part = ['Fr', 'Je', 'Ad', 'An', 'Ren', 'Gin', 'J', 'D'] | |
| Last_Name_Part = ['ancesca', 'oe', 'gela', 'am', 'ee', 'ff', 'ny', 'avid'] | |
| Real_Names = ['Francesca', 'Joe', 'Angela', 'Adam', 'Renee', 'Jeff', 'Ginny', 'David'] | |
| with open('shufflednames.txt', 'w') as file: | |
| file.write('This is your new name: ') | |
| file.write(nameshuffler(choice(First_Name_Part), choice(Last_Name_Part))) | |
| file.write(namegenerator()) | |
| print(all_shufflednames()) | |
| print(namegenerator()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment