Ask a question.

def ask(query, default=None):
    """Ask a question."""
    if default:
        default_q = ' [{0}]'.format(default)
    else:
        default_q = ''
    if sys.version_info[0] == 3:
        inp = input("{query}{default_q}: ".format(
            query=query, default_q=default_q)).strip()
    else:
        inp = raw_input("{query}{default_q}: ".format(
            query=query, default_q=default_q).encode('utf-8')).strip()
    if inp or default is None:
        return inp
    else:
        return default