Python - Store function references in a dictionary
You can translate this fragment into Python by arranging the choices and functions into a dictionary:
actions = {0: make_computer_move, 1: make_human_move}
actions.get(choice, report_error)()
You can translate this fragment into Python by arranging the choices and functions into a dictionary:
actions = {0: make_computer_move, 1: make_human_move}
actions.get(choice, report_error)()