Here is my code:
if head and head.next is None: return True current = head prev = None nex = None while current: nex = cur