Skip to content

Instantly share code, notes, and snippets.

@joemarchese
Created April 4, 2017 16:39
Show Gist options
  • Select an option

  • Save joemarchese/11082e9dd57ab40e628d4df1a247d76b to your computer and use it in GitHub Desktop.

Select an option

Save joemarchese/11082e9dd57ab40e628d4df1a247d76b to your computer and use it in GitHub Desktop.
"""
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