Create a gist now

Instantly share code, notes, and snippets.

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)
else:
print choice(first_names),choice(last_names)
print "* * * name generator for virtual GOLF players! * * *"
while True:
printRandomName()
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."
continue
valid_answer=True
if('n'==answer):
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment