class LNode(object):
def init(self,elem,next_=None):
self.elem = elem
self.next = next_
def reverseList(head):
if head==None or head.next ==None:
return
pre = None
next = None
while(head!=None):
next = head.next
head.next = pre
pre = head
head = next
return pre
if name == ‘main’:
l1 = LNode(11)
l1.next = LNode(21)
l1.next.next = LNode(4)
l = reverseList(l1)
print(l.elem,l.next.elem,l.next.next.elem)