def read_choice(li, dic):
    """Read user's choice and return the selected record."""
    print
    print("You can quit with 'q'.")
    while True:
        record = None
        try:
            choice = input("> ")
        except:
            print()
            exit(0)
        #
        if choice == '' or choice == 'q':
            exit(0)
        # else
        try:
            # if it's a number
            if str(int(choice)) == choice:
                choice = int(choice)
        except ValueError:
            pass

        try:
            if isinstance(choice, int) and choice > 0:
                record = li[choice]
            elif isinstance(choice, str):
                record = li[dic[choice]]
        except IndexError:
            pass
        except KeyError:
            pass

        if record:
            break

    return record