def reverseList(head):
# base case, returning the last element in the list
if head.next==None:
return head
# store the last node found recursively, to be returned
last = reverseList(head.next)
# set the next of curr node to curr node
head.next.next = head
# this will be changed recursively from None to the previous node
# except for the last(new)/first(old) node
head.next = None
return last