human
K | Function to find the kth digit from last in an integer n.
If k is less than equal to 0.
Convert integer into string.
If k is greater than length of the temp.
Print the k digit from last.
Driver code.
Given Input.
Function call"
How can the above be solved in Python?
assistant
#Here is code to k and the other steps required.
 def kthDigitFromLast ( n , k ) :
	if ( k <= 0 ) :
		print ( - 1 )
		return
	temp = str ( n )
	if ( k > len ( temp ) ) :
		print ( - 1 )
	else :
		print ( ord ( temp [ len ( temp ) - k ] ) - ord ( '0' ) )
if __name__ == ' _ _ main _ _ ' :
	n = 2354
	k = 2
	kthDigitFromLast ( n , k )