-6

I am facing indentation error despite correct spaces. I am not able to figure out the exact problem

Code region :

def reverse(self,pos):
cur=pos
prevnode =None
nextnode=None
while cur.next!=None:
        nextnode=cur.next
        cur.next=prevnode
        prevnode=cur
        cur=nextnode
        self.head=prevnode

error comes at this point :

File "python", line 75 nextnode=None ^ IndentationError: unexpected indent Here's the repl link :https://repl.it/@LJ1/ConstantPurpleDisk

Nimantha
  • 6,405
  • 6
  • 28
  • 69
leo
  • 69
  • 1
  • 8

1 Answers1

1

It should be like this

def reverse(self,pos):
    cur=pos
    prevnode=None
    nextnode=None

    while pos.next!=None:
      cur=self.head
      prevnode=None
      nextnode=None

      while cur.next!=None:
            nextnode=cur.next
            cur.next=prevnode
            prevnode=cur
            cur=nextnode
            self.head=prevnode
Nihal
  • 5,262
  • 7
  • 23
  • 41