Skip to content

Instantly share code, notes, and snippets.

@mscandizzo
Created March 25, 2016 01:30
Show Gist options
  • Save mscandizzo/11c22c71e9fdda297864 to your computer and use it in GitHub Desktop.
Save mscandizzo/11c22c71e9fdda297864 to your computer and use it in GitHub Desktop.
def drinks():
from collections import defaultdict
import random
questions = {
"strong": "Do you like your drinks strong?",
"salty": "Do you 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"],
}
answers = {}
response = {}
for key,value in questions.iteritems():
while True:
try:
val = raw_input(value)
if val == "yes" or val == "no":
break
else:
print("Let us try one more time, please only yes or no answers")
except:
print("You must provide only a yes or no questions, please try again:")
continue
if val == "yes":
answers[key] = True
response[key] = True
else:
response[key] = False
continue
#print (answers)
# The problem here is that the input box is not taking the value as string so you have to enter " " for the code to run and accept the yes or the no
coctel = {}
for key in ingredients:
for llave in answers:
if key == llave:
coctel[llave] = ingredients[llave]
print(coctel)
keys = list(coctel.values())
print (keys)
if __name__ == '__main__':
drinks()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment