Inf 124 - Proj 2 - view.py
# view.py - Display state to user
def get_choice_index_from_option_menu(option_list, question):
'''Prints a menu of options determined by the list with a question prompt and return the user's choice as the index of the selected item (index based on option_list)'''
validOptions = ""
print('')
for i in range(len(option_list)):
validOptions = validOptions + str(i)
print('{}.{}'.format(i+1, option_list[i]))
print('')
choice = str(input(question)-1)
# check if the choice is valid before returning the chosen index (index-1)
if choice != "" and choice in validOptions:
return int(choice)
else:
# raise exception
pass
def get_client_name():
''' Asks the client for their name and returns it '''
return raw_input('What is your name?')