def validate(string):
    """Return int(string) if string can be represented as an integer.
    Otherwise, re-return string unmodified.
    By the way, it also output an error message to the user."""
    try:
        return int(string)
    except ValueError:
        print("\nError: invalid value -> %s\n" % string)
        return string