def wrap_line(line, limit=None, chars=80):
    """Wraps the specified line of text on whitespace to make sure that none of the
    lines' lengths exceeds 'chars' characters.
    """
    result = []
    builder = []
    length = 0
    if limit is not None:
        sline = line[0:limit]
    else:
        sline = line
        
    for word in sline.split():
        if length <= chars:
            builder.append(word)
            length += len(word) + 1
        else:
            result.append(' '.join(builder))
            builder = [word]
            length = 0

    result.append(' '.join(builder))
    return result
def wrap_line ( line , limit = None , chars = 80 ) : result = [ ] builder = [ ] length = 0 if limit is not None : sline = line [ 0 : limit ] else : sline = line for word in sline . split ( ) : if length <= chars : builder . append ( word ) length += len ( word ) + 1 else : result . append ( ' ' . join ( builder ) ) builder = [ word ] length = 0 result . append ( ' ' . join ( builder ) ) return result
Wraps the specified line of text on whitespace to make sure that none of the
    lines' lengths exceeds 'chars' characters.