Created
September 11, 2015 16:01
-
-
Save AndyNovo/253f316346734790a61a 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
#My opening explanation | |
print(""" | |
Welcome to the Green Room. Where you can have | |
coffee but not tea, a muffin but not cake, and | |
pet a giraffe but not a cat. | |
Please ask me about an object and I'll tell you | |
if it is allowed. Tell me "quit" to stop the game. | |
You'll have to decide for yourself when you've won. | |
""") | |
# Students please add your function(s) here. | |
# call it is_in_green_room and have it consume a string | |
# and return True or False | |
# Some sample inputs: | |
# "banana" should return False | |
# "apple" should return True | |
# "Aardvark" should give True | |
# "Sewer Rat" should return False | |
#A function to ask the user for an object | |
def prompt_user(): | |
return input("Give me an object or \"quit\" to stop:") | |
#The starting object | |
user_object = prompt_user() | |
#The "Game Loop" will stop when someone says "quit" or "q" | |
while ( not (user_object == "quit" or user_object == "q")): | |
# ERROR, is_in_green_room is not defined! Help me students. | |
if is_in_green_room(user_object): | |
#The response for a success | |
print("{0} is allowed in the green room.".format(user_object)) | |
else: | |
#The response for a failure | |
print("{0} is forbidden from the green room.".format(user_object)) | |
#Be sure to ask them again for the next loop (can't be infinite) | |
user_object = prompt_user() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment