How would you reverse every k nodes in a linked list?
Implement reverse_k_group(head, k) using constant extra space. The input is a singly linked list and a positive integer k; return the modified head, leaving a final group smaller than k unchanged. For [1,2,3,4,5] with k = 2, return [2,1,4,3,5]; for k = 3, return [3,2,1,4,5].
def reverse_k_group(head, k):