Created
May 4, 2017 20:47
-
-
Save jmieleiii/2b11f2487490ff10d4355f069d80b91c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def prompt_user_select_difficulty(diffs_available): | |
difficulty_selected = raw_input( | |
"Please choose a difficulty:" | |
"\n\teasy" | |
"\n\tmedium" | |
"\n\thard" | |
"\n\texit\n> ").lower() | |
while difficulty_selected not in diffs_available: | |
difficulty_selected = raw_input("Please enter a valid difficulty\n> ").lower() | |
return difficulty_selected | |
def prompt_user_answer_challenge(prompt, answer_key): | |
print("Here's your clue!") | |
print(prompt) | |
user_answers = raw_input("Please enter your answers: __1__, __2__\n> ").split(',') | |
wrong_answer_count = 0 | |
for i in range(0, len(answer_key)): | |
if user_answers[i].strip() != answer_key[i]: | |
wrong_answer_count += 1 | |
else: | |
print("Correct!") | |
return wrong_answer_count | |
def play_game(): | |
difficulties_available = ['easy', 'medium', 'hard', 'exit'] | |
answers_for = { | |
'easy': ['1','2','3', '4', '5'], | |
'medium': [], | |
'hard': [] | |
} | |
prompts_for = { | |
'easy': '1, 2, 3, 4, 5', | |
'medium': 'Medium prompt', | |
'hard': 'Hard prompt' | |
} | |
difficulty_selected = prompt_user_select_difficulty(difficulties_available) | |
if difficulty_selected != 'exit': | |
wrong_answer_count = prompt_user_answer_challenge( | |
prompts_for[difficulty_selected], | |
answers_for[difficulty_selected] | |
) | |
print("You got {0} wrong answers".format(wrong_answer_count)) | |
else: | |
print('Bye') | |
play_game() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment