Skip to content

Instantly share code, notes, and snippets.

@MattSegal
Created July 20, 2017 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MattSegal/1d684ac3f794eb34393e53cd23c29a6b to your computer and use it in GitHub Desktop.
Save MattSegal/1d684ac3f794eb34393e53cd23c29a6b to your computer and use it in GitHub Desktop.
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