Function to reverse the linked list
def reverseList ( head_ref ) : NEW_LINE INDENT current = None NEW_LINE prev = None NEW_LINE next = None NEW_LINE current = head_ref NEW_LINE prev = None NEW_LINE while ( current != None ) : NEW_LINE INDENT next = current . next NEW_LINE current . next = prev NEW_LINE prev = current NEW_LINE current = next NEW_LINE DEDENT head_ref = prev NEW_LINE return head_ref NEW_LINE DEDENT