Skip to content

Instantly share code, notes, and snippets.

Created March 31, 2014 17:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#MonthOfCode day 29 - golf
from random import choice
mid_names = [ "" for i in xrange(7) ]
mid_names.extend( [ "Kindred", "Junior", "Senior", "Jack" ])
first_names = \
[ "Tiger", "Mike", "Edgar", "Jean-Paul", "Sandra", "Clara", "Gary", "Philip", "Edwin" ]
last_names = [ "Woods", "Jackson", "Nelson", "Watson", "Palmer", "Hagen", "Nicklaus", "Haeger", "de LaMartre" ]
def printRandomName():
mid = choice(mid_names)
has_mid_n = ( len(mid)>0 )
if( has_mid_n):
print choice(first_names),mid,choice(last_names)
print choice(first_names),choice(last_names)
print "* * * name generator for virtual GOLF players! * * *"
while True:
valid_answer = False
# the inner loop aims at validating the answer
while(not valid_answer):
print "generate another name? y/n"
answer = raw_input()
if( not ('y'==answer or 'n'==answer)):
print "answer y or n, please."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment