Reverse a linked list.
Asked in the Technical interview stage. Implement the function below for a singly linked list. The input is the head ListNode, and the function must return the new head after reversing all links. For grading, test cases represent linked lists as arrays of node values.
def reverse_list(head):
def reverse_list(head):