Created
July 20, 2017 03:57
-
-
Save MattSegal/1d684ac3f794eb34393e53cd23c29a6b to your computer and use it in GitHub Desktop.
This file contains 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 say_hello(): | |
print("Hello") | |
def say_bye(): | |
print("Bye") | |
def say_sup(): | |
print("Sup?") | |
choice_lookup = { | |
"hello": say_hello, | |
"bye": say_bye, | |
"sup": say_sup, | |
} | |
user_choice = input("What do you want the computer to say? [ hello / bye / sup ]: ") | |
try: | |
chosen_func = choice_lookup[user_choice] | |
chosen_func() | |
except KeyError: | |
print("Error: you can only choose hello / bye / sup") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment