Created
September 26, 2016 06:29
-
-
Save dmsurti/25cda12c1372c389f96e09c9c5894d75 to your computer and use it in GitHub Desktop.
Bartender (Submission by Hans)
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
import random | |
questions = { | |
"strong": "Do ye like yer drinks strong?", | |
"salty": "Do ye like it with a salty tang?", | |
"bitter": "Are ye a lubber who likes it bitter?", | |
"sweet": "Would ye like a bit of sweetness with yer poison?", | |
"fruity": "Are ye one for a fruity finish?", | |
} | |
ingredients = { | |
"strong": ["glug of rum", "slug of whisky", "splash of gin"], | |
"salty": ["olive on a stick", "salt-dusted rim", "rasher of bacon"], | |
"bitter": ["shake of bitters", "splash of tonic", "twist of lemon peel"], | |
"sweet": ["sugar cube", "spoonful of honey", "spash of cola"], | |
"fruity": ["slice of orange", "dash of cassis", "cherry on top"], | |
} | |
def ask(): | |
answers = {} | |
for key in questions.keys(): | |
answers[key] = input(questions[key] + " ") | |
return answers | |
def tend(answers): | |
print('\n\nHere we go:\n') | |
for key in answers.keys(): | |
if answers[key] != "": | |
if answers[key].lower()[0] == 'y': | |
print(random.choice(ingredients[key])) | |
print('\n\n') | |
if __name__ == '__main__': | |
answers = ask() | |
tend(answers) |
if answers[key] != "":
if answers[key].lower()[0] == 'y':
This is better implemented as if answers[key]:
, see my previous comment.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would be preferable to store the
answers[key]
as a Boolean. That will simplify when you pick the random ingredient intend
.Further, the instruction asks to store the answer as a Boolean.