Created
February 1, 2015 04:49
-
-
Save insipx/fda078e6104eebd61124 to your computer and use it in GitHub Desktop.
This file contains 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
import random | |
def sample(items): | |
randomIndex = random.randrange(len(items)) | |
return items[randomIndex] | |
def promptForGender(): | |
genderList = ["male", "female"] | |
response = input("What Name Gender would you like? (m/f) (enter 'r' for random)") | |
response = response.lower() | |
if response == "m": | |
return "male" | |
elif response == "f": | |
return "female" | |
elif response == "r": | |
return sample(genderList) | |
else: | |
print ("please enter 'M' ,'F', or 'R' to initiate the Random Name Generator") | |
def genName(): | |
boyNames = ["Jack", "Andrew", "Mike", "Terry", "Torvald", "Gatsby"] | |
girlNames = ["Alice", "Hana", "Clare", "Janet", "Daisy"] | |
gender = promptForGender() | |
if gender == "male": | |
return sample(boyNames) | |
elif gender == "female": | |
return sample(girlNames) | |
print ("Welcome to the Simple Random Name Generator by Liquid Think!") | |
print (genName()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment