Kth space | Function to prkth integer in a given string ; Size of the string ; If space char found decrement K ; If K becomes 1 , the next string is the required one ; Print required number ; Driver Code ; Given string ; Given K ; Function call
def print_kth_string ( s , K ) : NEW_LINE INDENT N = len ( s ) ; NEW_LINE for i in range ( 0 , N , 1 ) : NEW_LINE INDENT if ( s [ i ] == ' ▁ ' ) : NEW_LINE INDENT K -= 1 ; NEW_LINE DEDENT if ( K == 1 ) : NEW_LINE INDENT break ; NEW_LINE DEDENT DEDENT while ( i < N ) : NEW_LINE INDENT if ( s [ i ] != ' ▁ ' ) : NEW_LINE INDENT print ( s [ i ] , end = " " ) ; NEW_LINE DEDENT i += 1 ; NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT s = "10 ▁ 20 ▁ 30 ▁ 40" ; NEW_LINE K = 4 ; NEW_LINE print_kth_string ( s , K ) ; NEW_LINE DEDENT