It would be cleaner if those functions returned the answer, or raise an exception, e.g:
selected_key=key() selected_tone=tone() selected_level=level()level() probably should not be an embedded function, but should live at the same level as key() and tone()