title: Deleting a linked-list node at a given position
body: <p>I have solved this particular problem using Recursion but I am not able to solve this question using <strong><em>While loop</em></strong>. Here's my code, error, and the link to the question:</p>
  
  <p><a href="https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list</a></p>
  
  <p><strong>Code</strong></p>
  
  <pre><code>def Delete(head, position):
      list=head
      while(position-1):
          head=head.next
          position=position-1
      add=head.next
      head.next=add.next
      return list
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <pre><code>Traceback (most recent call last):
  File "solution.py", line 76, in &lt;module&gt;
  head = Delete(L1.head, p)
  File "solution.py", line 60, in Delete
  head=head.next
  AttributeError: 'NoneType' object has no attribute 'next'
  </code></pre>