def trunc(s, n):
    """
    Truncate a string to N characters, appending '...' if truncated.

      trunc('1234567890', 10) -> '1234567890'
      trunc('12345678901', 10) -> '1234567890...'
    """
    if not s:
        return s
    return s[:n] + "..." if len(s) > n else s