simply add n - k smallest characters
if ( k > n ) : NEW_LINE INDENT print ( s , end = " " ) NEW_LINE for i in range ( n , k , 1 ) : NEW_LINE INDENT print ( v [ 0 ] , end = " " ) NEW_LINE DEDENT return ; NEW_LINE DEDENT