(self, x, pos)
| 48 | |
| 49 | #method to insert an element at a specific position |
| 50 | def insert(self, x, pos): |
| 51 | if pos == 1: |
| 52 | self.addFront(x) |
| 53 | return |
| 54 | if pos == (self.count()+1): |
| 55 | self.addTail(x) |
| 56 | return |
| 57 | new_node = Node(x) |
| 58 | temp = self.head |
| 59 | i = 1 |
| 60 | while (temp != None) and (i < pos-1): |
| 61 | temp = temp.next |
| 62 | i += 1 |
| 63 | if (temp == None): |
| 64 | return |
| 65 | new_node.next = temp.next |
| 66 | temp.next = new_node |
| 67 | |
| 68 | #method to remove the head in the list |
| 69 | def removeHead(self): |